{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import os\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import seaborn as sns\n",
    "sns.set(color_codes=True)\n",
    "from sklearn.metrics import mean_squared_error as mse\n",
    "from sklearn.preprocessing import Imputer\n",
    "from sklearn.preprocessing import LabelBinarizer,OneHotEncoder,LabelEncoder\n",
    "# 设置jupyter数据框最大显示的列数\n",
    "pd.set_option('max_columns',100)\n",
    "from pylab import mpl\n",
    "mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体\n",
    "mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题\n",
    "mpl.rcParams['axes.titlesize'] = 16\n",
    "from dateutil.parser import parse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 读取数据\n",
    "train = pd.read_csv('../d_train_20180102.csv',encoding='gb2312',index_col='id')\n",
    "test = pd.read_csv('../d_test_A_20180102.csv',encoding='gb2312',index_col='id')\n",
    "test_real_y = pd.read_csv('../d_answer_a_20180128.csv',encoding='gb2312',header=None)\n",
    "test_b = pd.read_csv('../d_test_B_20180128.csv',encoding='gb2312',index_col='id')\n",
    "# train = data_train.copy()\n",
    "# test = data_test.copy()\n",
    "\n",
    "# 把血糖单独拿出来\n",
    "y = train['血糖']\n",
    "train.drop('血糖',axis=1,inplace=True)\n",
    "data = pd.concat([train,test])\n",
    "combined = pd.concat([data,test_b])\n",
    "train_index ,test_index = data.index, test_b.index\n",
    "combined_copy = combined.fillna(combined.median(axis=0))\n",
    "# features_drop = ['体检日期','乙肝表面抗原','乙肝表面抗体','乙肝e抗原','乙肝e抗体','乙肝核心抗体']\n",
    "\n",
    "# train.drop(features_drop,axis=1,inplace=True)\n",
    "# test.drop(features_drop,axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7642, 40)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "combined.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# combined_cut.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 连续特征分箱 # 按照列名的顺序\n",
    "# 不算 '乙肝表面抗原','乙肝表面抗体','乙肝e抗原','乙肝e抗体','乙肝核心抗体'\n",
    "cut_interval = [[-np.inf,15,40,np.inf],[-1,6,24,np.inf],[-1,45,135,np.inf],[-1,50,np.inf],[-1,60,85,np.inf],[-1,35,51,np.inf],\n",
    "                [-1,20,30,np.inf],[-1,1.5,2.5,np.inf],[-1,0.45,1.69,np.inf],[-1,2.85,5.69,np.inf],[-1,1.4,np.inf],[-1,2,4,np.inf],\n",
    "               [-1,2,7.1,np.inf],[-1,44,133,np.inf],[-1,250,450,np.inf],[-1,3.5,9.5,np.inf],[-1,4,5.5,np.inf],[-1,115,175,np.inf],\n",
    "               [-1,0.35,0.5,np.inf],[-1,82,93,np.inf],[-1,26,38,np.inf],[-1,325,350,np.inf],[-1,12,14,np.inf],[-1,100,350,np.inf],\n",
    "               [-1,6,11.5,np.inf],[-1,10,17,np.inf],[-1,0.11,0.23,np.inf],[-1,55,70,np.inf],[-1,20,40,np.inf],[-1,3,8,np.inf],\n",
    "                [-1,1,5,np.inf],[-1,1,np.inf]]\n",
    "cut_features = list(combined.drop(['乙肝表面抗原','乙肝表面抗体','乙肝e抗原','乙肝e抗体','乙肝核心抗体','性别','年龄','体检日期'],\n",
    "                                  axis=1).columns)\n",
    "combined_cut = pd.DataFrame()\n",
    "\n",
    "for i,feature in enumerate(cut_features):\n",
    "#     print(i)\n",
    "    cut_inter = cut_interval[i]\n",
    "    cut_num = [-1,0,1]\n",
    "    if len(cut_inter) < 4:\n",
    "        cut_num = [0,1]\n",
    "    s = pd.Series(pd.cut(combined_copy[feature],bins=cut_inter,labels=cut_num),name='cut_'+feature)\n",
    "    combined_cut = pd.concat([combined_cut,s],axis=1)\n",
    "combined_cut.index = combined.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年龄*年龄</th>\n",
       "      <th>年龄**天门冬氨酸氨基转换酶</th>\n",
       "      <th>年龄**丙氨酸氨基转换酶</th>\n",
       "      <th>年龄**碱性磷酸酶</th>\n",
       "      <th>年龄**r-谷氨酰基转换酶</th>\n",
       "      <th>年龄**总蛋白</th>\n",
       "      <th>年龄*白蛋白</th>\n",
       "      <th>年龄**球蛋白</th>\n",
       "      <th>年龄*白球比例</th>\n",
       "      <th>年龄*甘油三酯</th>\n",
       "      <th>年龄*总胆固醇</th>\n",
       "      <th>年龄*高密度脂蛋白胆固醇</th>\n",
       "      <th>年龄*低密度脂蛋白胆固醇</th>\n",
       "      <th>年龄*尿素</th>\n",
       "      <th>年龄*肌酐</th>\n",
       "      <th>年龄*尿酸</th>\n",
       "      <th>年龄*乙肝表面抗原</th>\n",
       "      <th>年龄*乙肝表面抗体</th>\n",
       "      <th>年龄*乙肝e抗原</th>\n",
       "      <th>年龄*乙肝e抗体</th>\n",
       "      <th>年龄*乙肝核心抗体</th>\n",
       "      <th>年龄*白细胞计数</th>\n",
       "      <th>年龄*红细胞计数</th>\n",
       "      <th>年龄*血红蛋白</th>\n",
       "      <th>年龄*红细胞压积</th>\n",
       "      <th>年龄*红细胞平均体积</th>\n",
       "      <th>年龄*红细胞平均血红蛋白量</th>\n",
       "      <th>年龄*红细胞平均血红蛋白浓度</th>\n",
       "      <th>年龄*红细胞体积分布宽度</th>\n",
       "      <th>年龄*血小板计数</th>\n",
       "      <th>年龄*血小板平均体积</th>\n",
       "      <th>年龄*血小板体积分布宽度</th>\n",
       "      <th>年龄*血小板比积</th>\n",
       "      <th>年龄*中性粒细胞%</th>\n",
       "      <th>年龄*淋巴细胞%</th>\n",
       "      <th>年龄*单核细胞%</th>\n",
       "      <th>年龄*嗜酸细胞%</th>\n",
       "      <th>年龄*嗜碱细胞%</th>\n",
       "      <th>*天门冬氨酸氨基转换酶**天门冬氨酸氨基转换酶</th>\n",
       "      <th>*天门冬氨酸氨基转换酶**丙氨酸氨基转换酶</th>\n",
       "      <th>*天门冬氨酸氨基转换酶**碱性磷酸酶</th>\n",
       "      <th>*天门冬氨酸氨基转换酶**r-谷氨酰基转换酶</th>\n",
       "      <th>*天门冬氨酸氨基转换酶**总蛋白</th>\n",
       "      <th>*天门冬氨酸氨基转换酶*白蛋白</th>\n",
       "      <th>*天门冬氨酸氨基转换酶**球蛋白</th>\n",
       "      <th>*天门冬氨酸氨基转换酶*白球比例</th>\n",
       "      <th>*天门冬氨酸氨基转换酶*甘油三酯</th>\n",
       "      <th>*天门冬氨酸氨基转换酶*总胆固醇</th>\n",
       "      <th>*天门冬氨酸氨基转换酶*高密度脂蛋白胆固醇</th>\n",
       "      <th>*天门冬氨酸氨基转换酶*低密度脂蛋白胆固醇</th>\n",
       "      <th>...</th>\n",
       "      <th>红细胞体积分布宽度*中性粒细胞%</th>\n",
       "      <th>红细胞体积分布宽度*淋巴细胞%</th>\n",
       "      <th>红细胞体积分布宽度*单核细胞%</th>\n",
       "      <th>红细胞体积分布宽度*嗜酸细胞%</th>\n",
       "      <th>红细胞体积分布宽度*嗜碱细胞%</th>\n",
       "      <th>血小板计数*血小板计数</th>\n",
       "      <th>血小板计数*血小板平均体积</th>\n",
       "      <th>血小板计数*血小板体积分布宽度</th>\n",
       "      <th>血小板计数*血小板比积</th>\n",
       "      <th>血小板计数*中性粒细胞%</th>\n",
       "      <th>血小板计数*淋巴细胞%</th>\n",
       "      <th>血小板计数*单核细胞%</th>\n",
       "      <th>血小板计数*嗜酸细胞%</th>\n",
       "      <th>血小板计数*嗜碱细胞%</th>\n",
       "      <th>血小板平均体积*血小板平均体积</th>\n",
       "      <th>血小板平均体积*血小板体积分布宽度</th>\n",
       "      <th>血小板平均体积*血小板比积</th>\n",
       "      <th>血小板平均体积*中性粒细胞%</th>\n",
       "      <th>血小板平均体积*淋巴细胞%</th>\n",
       "      <th>血小板平均体积*单核细胞%</th>\n",
       "      <th>血小板平均体积*嗜酸细胞%</th>\n",
       "      <th>血小板平均体积*嗜碱细胞%</th>\n",
       "      <th>血小板体积分布宽度*血小板体积分布宽度</th>\n",
       "      <th>血小板体积分布宽度*血小板比积</th>\n",
       "      <th>血小板体积分布宽度*中性粒细胞%</th>\n",
       "      <th>血小板体积分布宽度*淋巴细胞%</th>\n",
       "      <th>血小板体积分布宽度*单核细胞%</th>\n",
       "      <th>血小板体积分布宽度*嗜酸细胞%</th>\n",
       "      <th>血小板体积分布宽度*嗜碱细胞%</th>\n",
       "      <th>血小板比积*血小板比积</th>\n",
       "      <th>血小板比积*中性粒细胞%</th>\n",
       "      <th>血小板比积*淋巴细胞%</th>\n",
       "      <th>血小板比积*单核细胞%</th>\n",
       "      <th>血小板比积*嗜酸细胞%</th>\n",
       "      <th>血小板比积*嗜碱细胞%</th>\n",
       "      <th>中性粒细胞%*中性粒细胞%</th>\n",
       "      <th>中性粒细胞%*淋巴细胞%</th>\n",
       "      <th>中性粒细胞%*单核细胞%</th>\n",
       "      <th>中性粒细胞%*嗜酸细胞%</th>\n",
       "      <th>中性粒细胞%*嗜碱细胞%</th>\n",
       "      <th>淋巴细胞%*淋巴细胞%</th>\n",
       "      <th>淋巴细胞%*单核细胞%</th>\n",
       "      <th>淋巴细胞%*嗜酸细胞%</th>\n",
       "      <th>淋巴细胞%*嗜碱细胞%</th>\n",
       "      <th>单核细胞%*单核细胞%</th>\n",
       "      <th>单核细胞%*嗜酸细胞%</th>\n",
       "      <th>单核细胞%*嗜碱细胞%</th>\n",
       "      <th>嗜酸细胞%*嗜酸细胞%</th>\n",
       "      <th>嗜酸细胞%*嗜碱细胞%</th>\n",
       "      <th>嗜碱细胞%*嗜碱细胞%</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1681</td>\n",
       "      <td>1023.36</td>\n",
       "      <td>947.10</td>\n",
       "      <td>4083.19</td>\n",
       "      <td>829.43</td>\n",
       "      <td>3152.08</td>\n",
       "      <td>2033.60</td>\n",
       "      <td>1118.48</td>\n",
       "      <td>74.62</td>\n",
       "      <td>53.71</td>\n",
       "      <td>181.63</td>\n",
       "      <td>56.17</td>\n",
       "      <td>108.65</td>\n",
       "      <td>240.67</td>\n",
       "      <td>3167.25</td>\n",
       "      <td>14324.99</td>\n",
       "      <td>1.64</td>\n",
       "      <td>132.02</td>\n",
       "      <td>1.64</td>\n",
       "      <td>68.47</td>\n",
       "      <td>69.29</td>\n",
       "      <td>218.94</td>\n",
       "      <td>213.61</td>\n",
       "      <td>6810.1</td>\n",
       "      <td>19.639</td>\n",
       "      <td>3767.9</td>\n",
       "      <td>1307.9</td>\n",
       "      <td>14227.0</td>\n",
       "      <td>524.8</td>\n",
       "      <td>6806.0</td>\n",
       "      <td>405.9</td>\n",
       "      <td>713.4</td>\n",
       "      <td>6.724</td>\n",
       "      <td>2218.1</td>\n",
       "      <td>1402.2</td>\n",
       "      <td>266.5</td>\n",
       "      <td>192.7</td>\n",
       "      <td>24.6</td>\n",
       "      <td>623.0016</td>\n",
       "      <td>576.5760</td>\n",
       "      <td>2485.7664</td>\n",
       "      <td>504.9408</td>\n",
       "      <td>1918.9248</td>\n",
       "      <td>1238.0160</td>\n",
       "      <td>680.9088</td>\n",
       "      <td>45.4272</td>\n",
       "      <td>32.6976</td>\n",
       "      <td>110.5728</td>\n",
       "      <td>34.1952</td>\n",
       "      <td>66.1440</td>\n",
       "      <td>...</td>\n",
       "      <td>692.48</td>\n",
       "      <td>437.76</td>\n",
       "      <td>83.20</td>\n",
       "      <td>60.16</td>\n",
       "      <td>7.68</td>\n",
       "      <td>27556.0</td>\n",
       "      <td>1643.4</td>\n",
       "      <td>2888.4</td>\n",
       "      <td>27.224</td>\n",
       "      <td>8980.6</td>\n",
       "      <td>5677.2</td>\n",
       "      <td>1079.0</td>\n",
       "      <td>780.2</td>\n",
       "      <td>99.6</td>\n",
       "      <td>98.01</td>\n",
       "      <td>172.26</td>\n",
       "      <td>1.6236</td>\n",
       "      <td>535.59</td>\n",
       "      <td>338.58</td>\n",
       "      <td>64.35</td>\n",
       "      <td>46.53</td>\n",
       "      <td>5.94</td>\n",
       "      <td>302.76</td>\n",
       "      <td>2.8536</td>\n",
       "      <td>941.34</td>\n",
       "      <td>595.08</td>\n",
       "      <td>113.10</td>\n",
       "      <td>81.78</td>\n",
       "      <td>10.44</td>\n",
       "      <td>0.026896</td>\n",
       "      <td>8.8724</td>\n",
       "      <td>5.6088</td>\n",
       "      <td>1.0660</td>\n",
       "      <td>0.7708</td>\n",
       "      <td>0.0984</td>\n",
       "      <td>2926.81</td>\n",
       "      <td>1850.22</td>\n",
       "      <td>351.65</td>\n",
       "      <td>254.27</td>\n",
       "      <td>32.46</td>\n",
       "      <td>1169.64</td>\n",
       "      <td>222.30</td>\n",
       "      <td>160.74</td>\n",
       "      <td>20.52</td>\n",
       "      <td>42.25</td>\n",
       "      <td>30.55</td>\n",
       "      <td>3.90</td>\n",
       "      <td>22.09</td>\n",
       "      <td>2.82</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1681</td>\n",
       "      <td>1007.37</td>\n",
       "      <td>1486.25</td>\n",
       "      <td>2755.61</td>\n",
       "      <td>3239.00</td>\n",
       "      <td>3256.63</td>\n",
       "      <td>1958.16</td>\n",
       "      <td>1298.47</td>\n",
       "      <td>61.91</td>\n",
       "      <td>115.21</td>\n",
       "      <td>166.46</td>\n",
       "      <td>38.13</td>\n",
       "      <td>107.83</td>\n",
       "      <td>215.66</td>\n",
       "      <td>3571.92</td>\n",
       "      <td>19957.98</td>\n",
       "      <td>1.64</td>\n",
       "      <td>132.02</td>\n",
       "      <td>1.64</td>\n",
       "      <td>68.47</td>\n",
       "      <td>69.29</td>\n",
       "      <td>313.65</td>\n",
       "      <td>213.61</td>\n",
       "      <td>6396.0</td>\n",
       "      <td>18.696</td>\n",
       "      <td>3587.5</td>\n",
       "      <td>1225.9</td>\n",
       "      <td>14022.0</td>\n",
       "      <td>549.4</td>\n",
       "      <td>11357.0</td>\n",
       "      <td>377.2</td>\n",
       "      <td>422.3</td>\n",
       "      <td>10.660</td>\n",
       "      <td>2132.0</td>\n",
       "      <td>1504.7</td>\n",
       "      <td>237.8</td>\n",
       "      <td>192.7</td>\n",
       "      <td>32.8</td>\n",
       "      <td>603.6849</td>\n",
       "      <td>890.6625</td>\n",
       "      <td>1651.3497</td>\n",
       "      <td>1941.0300</td>\n",
       "      <td>1951.5951</td>\n",
       "      <td>1173.4632</td>\n",
       "      <td>778.1319</td>\n",
       "      <td>37.1007</td>\n",
       "      <td>69.0417</td>\n",
       "      <td>99.7542</td>\n",
       "      <td>22.8501</td>\n",
       "      <td>64.6191</td>\n",
       "      <td>...</td>\n",
       "      <td>696.80</td>\n",
       "      <td>491.78</td>\n",
       "      <td>77.72</td>\n",
       "      <td>62.98</td>\n",
       "      <td>10.72</td>\n",
       "      <td>76729.0</td>\n",
       "      <td>2548.4</td>\n",
       "      <td>2853.1</td>\n",
       "      <td>72.020</td>\n",
       "      <td>14404.0</td>\n",
       "      <td>10165.9</td>\n",
       "      <td>1606.6</td>\n",
       "      <td>1301.9</td>\n",
       "      <td>221.6</td>\n",
       "      <td>84.64</td>\n",
       "      <td>94.76</td>\n",
       "      <td>2.3920</td>\n",
       "      <td>478.40</td>\n",
       "      <td>337.64</td>\n",
       "      <td>53.36</td>\n",
       "      <td>43.24</td>\n",
       "      <td>7.36</td>\n",
       "      <td>106.09</td>\n",
       "      <td>2.6780</td>\n",
       "      <td>535.60</td>\n",
       "      <td>378.01</td>\n",
       "      <td>59.74</td>\n",
       "      <td>48.41</td>\n",
       "      <td>8.24</td>\n",
       "      <td>0.067600</td>\n",
       "      <td>13.5200</td>\n",
       "      <td>9.5420</td>\n",
       "      <td>1.5080</td>\n",
       "      <td>1.2220</td>\n",
       "      <td>0.2080</td>\n",
       "      <td>2704.00</td>\n",
       "      <td>1908.40</td>\n",
       "      <td>301.60</td>\n",
       "      <td>244.40</td>\n",
       "      <td>41.60</td>\n",
       "      <td>1346.89</td>\n",
       "      <td>212.86</td>\n",
       "      <td>172.49</td>\n",
       "      <td>29.36</td>\n",
       "      <td>33.64</td>\n",
       "      <td>27.26</td>\n",
       "      <td>4.64</td>\n",
       "      <td>22.09</td>\n",
       "      <td>3.76</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2116</td>\n",
       "      <td>957.72</td>\n",
       "      <td>700.58</td>\n",
       "      <td>2929.74</td>\n",
       "      <td>1755.82</td>\n",
       "      <td>3966.58</td>\n",
       "      <td>2208.00</td>\n",
       "      <td>1758.58</td>\n",
       "      <td>57.96</td>\n",
       "      <td>45.54</td>\n",
       "      <td>189.98</td>\n",
       "      <td>75.44</td>\n",
       "      <td>92.46</td>\n",
       "      <td>219.42</td>\n",
       "      <td>3596.74</td>\n",
       "      <td>20795.22</td>\n",
       "      <td>0.46</td>\n",
       "      <td>0.92</td>\n",
       "      <td>0.46</td>\n",
       "      <td>63.02</td>\n",
       "      <td>49.22</td>\n",
       "      <td>211.60</td>\n",
       "      <td>218.96</td>\n",
       "      <td>6844.8</td>\n",
       "      <td>20.148</td>\n",
       "      <td>4227.4</td>\n",
       "      <td>1439.8</td>\n",
       "      <td>15640.0</td>\n",
       "      <td>598.0</td>\n",
       "      <td>11086.0</td>\n",
       "      <td>381.8</td>\n",
       "      <td>763.6</td>\n",
       "      <td>9.154</td>\n",
       "      <td>2212.6</td>\n",
       "      <td>1853.8</td>\n",
       "      <td>354.2</td>\n",
       "      <td>147.2</td>\n",
       "      <td>36.8</td>\n",
       "      <td>433.4724</td>\n",
       "      <td>317.0886</td>\n",
       "      <td>1326.0258</td>\n",
       "      <td>794.6994</td>\n",
       "      <td>1795.3086</td>\n",
       "      <td>999.3600</td>\n",
       "      <td>795.9486</td>\n",
       "      <td>26.2332</td>\n",
       "      <td>20.6118</td>\n",
       "      <td>85.9866</td>\n",
       "      <td>34.1448</td>\n",
       "      <td>41.8482</td>\n",
       "      <td>...</td>\n",
       "      <td>625.30</td>\n",
       "      <td>523.90</td>\n",
       "      <td>100.10</td>\n",
       "      <td>41.60</td>\n",
       "      <td>10.40</td>\n",
       "      <td>58081.0</td>\n",
       "      <td>2000.3</td>\n",
       "      <td>4000.6</td>\n",
       "      <td>47.959</td>\n",
       "      <td>11592.1</td>\n",
       "      <td>9712.3</td>\n",
       "      <td>1855.7</td>\n",
       "      <td>771.2</td>\n",
       "      <td>192.8</td>\n",
       "      <td>68.89</td>\n",
       "      <td>137.78</td>\n",
       "      <td>1.6517</td>\n",
       "      <td>399.23</td>\n",
       "      <td>334.49</td>\n",
       "      <td>63.91</td>\n",
       "      <td>26.56</td>\n",
       "      <td>6.64</td>\n",
       "      <td>275.56</td>\n",
       "      <td>3.3034</td>\n",
       "      <td>798.46</td>\n",
       "      <td>668.98</td>\n",
       "      <td>127.82</td>\n",
       "      <td>53.12</td>\n",
       "      <td>13.28</td>\n",
       "      <td>0.039601</td>\n",
       "      <td>9.5719</td>\n",
       "      <td>8.0197</td>\n",
       "      <td>1.5323</td>\n",
       "      <td>0.6368</td>\n",
       "      <td>0.1592</td>\n",
       "      <td>2313.61</td>\n",
       "      <td>1938.43</td>\n",
       "      <td>370.37</td>\n",
       "      <td>153.92</td>\n",
       "      <td>38.48</td>\n",
       "      <td>1624.09</td>\n",
       "      <td>310.31</td>\n",
       "      <td>128.96</td>\n",
       "      <td>32.24</td>\n",
       "      <td>59.29</td>\n",
       "      <td>24.64</td>\n",
       "      <td>6.16</td>\n",
       "      <td>10.24</td>\n",
       "      <td>2.56</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>484</td>\n",
       "      <td>329.78</td>\n",
       "      <td>232.98</td>\n",
       "      <td>1629.76</td>\n",
       "      <td>444.84</td>\n",
       "      <td>1561.56</td>\n",
       "      <td>968.44</td>\n",
       "      <td>593.12</td>\n",
       "      <td>35.86</td>\n",
       "      <td>23.32</td>\n",
       "      <td>151.58</td>\n",
       "      <td>31.46</td>\n",
       "      <td>110.88</td>\n",
       "      <td>93.06</td>\n",
       "      <td>1352.12</td>\n",
       "      <td>8114.70</td>\n",
       "      <td>0.88</td>\n",
       "      <td>70.84</td>\n",
       "      <td>0.88</td>\n",
       "      <td>36.74</td>\n",
       "      <td>37.18</td>\n",
       "      <td>205.92</td>\n",
       "      <td>94.38</td>\n",
       "      <td>3014.0</td>\n",
       "      <td>8.866</td>\n",
       "      <td>2065.8</td>\n",
       "      <td>701.8</td>\n",
       "      <td>7480.0</td>\n",
       "      <td>277.2</td>\n",
       "      <td>5544.0</td>\n",
       "      <td>226.6</td>\n",
       "      <td>237.6</td>\n",
       "      <td>5.720</td>\n",
       "      <td>917.4</td>\n",
       "      <td>1023.0</td>\n",
       "      <td>147.4</td>\n",
       "      <td>101.2</td>\n",
       "      <td>11.0</td>\n",
       "      <td>224.7001</td>\n",
       "      <td>158.7441</td>\n",
       "      <td>1110.4592</td>\n",
       "      <td>303.0978</td>\n",
       "      <td>1063.9902</td>\n",
       "      <td>659.8598</td>\n",
       "      <td>404.1304</td>\n",
       "      <td>24.4337</td>\n",
       "      <td>15.8894</td>\n",
       "      <td>103.2811</td>\n",
       "      <td>21.4357</td>\n",
       "      <td>75.5496</td>\n",
       "      <td>...</td>\n",
       "      <td>525.42</td>\n",
       "      <td>585.90</td>\n",
       "      <td>84.42</td>\n",
       "      <td>57.96</td>\n",
       "      <td>6.30</td>\n",
       "      <td>63504.0</td>\n",
       "      <td>2595.6</td>\n",
       "      <td>2721.6</td>\n",
       "      <td>65.520</td>\n",
       "      <td>10508.4</td>\n",
       "      <td>11718.0</td>\n",
       "      <td>1688.4</td>\n",
       "      <td>1159.2</td>\n",
       "      <td>126.0</td>\n",
       "      <td>106.09</td>\n",
       "      <td>111.24</td>\n",
       "      <td>2.6780</td>\n",
       "      <td>429.51</td>\n",
       "      <td>478.95</td>\n",
       "      <td>69.01</td>\n",
       "      <td>47.38</td>\n",
       "      <td>5.15</td>\n",
       "      <td>116.64</td>\n",
       "      <td>2.8080</td>\n",
       "      <td>450.36</td>\n",
       "      <td>502.20</td>\n",
       "      <td>72.36</td>\n",
       "      <td>49.68</td>\n",
       "      <td>5.40</td>\n",
       "      <td>0.067600</td>\n",
       "      <td>10.8420</td>\n",
       "      <td>12.0900</td>\n",
       "      <td>1.7420</td>\n",
       "      <td>1.1960</td>\n",
       "      <td>0.1300</td>\n",
       "      <td>1738.89</td>\n",
       "      <td>1939.05</td>\n",
       "      <td>279.39</td>\n",
       "      <td>191.82</td>\n",
       "      <td>20.85</td>\n",
       "      <td>2162.25</td>\n",
       "      <td>311.55</td>\n",
       "      <td>213.90</td>\n",
       "      <td>23.25</td>\n",
       "      <td>44.89</td>\n",
       "      <td>30.82</td>\n",
       "      <td>3.35</td>\n",
       "      <td>21.16</td>\n",
       "      <td>2.30</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2304</td>\n",
       "      <td>963.36</td>\n",
       "      <td>709.44</td>\n",
       "      <td>3637.92</td>\n",
       "      <td>1090.56</td>\n",
       "      <td>3746.40</td>\n",
       "      <td>2007.84</td>\n",
       "      <td>1738.56</td>\n",
       "      <td>55.20</td>\n",
       "      <td>46.56</td>\n",
       "      <td>257.76</td>\n",
       "      <td>60.96</td>\n",
       "      <td>175.20</td>\n",
       "      <td>233.28</td>\n",
       "      <td>3704.64</td>\n",
       "      <td>16400.16</td>\n",
       "      <td>1.92</td>\n",
       "      <td>154.56</td>\n",
       "      <td>1.92</td>\n",
       "      <td>80.16</td>\n",
       "      <td>81.12</td>\n",
       "      <td>243.36</td>\n",
       "      <td>247.20</td>\n",
       "      <td>5088.0</td>\n",
       "      <td>16.992</td>\n",
       "      <td>3297.6</td>\n",
       "      <td>988.8</td>\n",
       "      <td>14352.0</td>\n",
       "      <td>796.8</td>\n",
       "      <td>15168.0</td>\n",
       "      <td>532.8</td>\n",
       "      <td>672.0</td>\n",
       "      <td>16.800</td>\n",
       "      <td>2716.8</td>\n",
       "      <td>1588.8</td>\n",
       "      <td>436.8</td>\n",
       "      <td>28.8</td>\n",
       "      <td>28.8</td>\n",
       "      <td>402.8049</td>\n",
       "      <td>296.6346</td>\n",
       "      <td>1521.1053</td>\n",
       "      <td>455.9904</td>\n",
       "      <td>1566.4635</td>\n",
       "      <td>839.5281</td>\n",
       "      <td>726.9354</td>\n",
       "      <td>23.0805</td>\n",
       "      <td>19.4679</td>\n",
       "      <td>107.7759</td>\n",
       "      <td>25.4889</td>\n",
       "      <td>73.2555</td>\n",
       "      <td>...</td>\n",
       "      <td>939.56</td>\n",
       "      <td>549.46</td>\n",
       "      <td>151.06</td>\n",
       "      <td>9.96</td>\n",
       "      <td>9.96</td>\n",
       "      <td>99856.0</td>\n",
       "      <td>3507.6</td>\n",
       "      <td>4424.0</td>\n",
       "      <td>110.600</td>\n",
       "      <td>17885.6</td>\n",
       "      <td>10459.6</td>\n",
       "      <td>2875.6</td>\n",
       "      <td>189.6</td>\n",
       "      <td>189.6</td>\n",
       "      <td>123.21</td>\n",
       "      <td>155.40</td>\n",
       "      <td>3.8850</td>\n",
       "      <td>628.26</td>\n",
       "      <td>367.41</td>\n",
       "      <td>101.01</td>\n",
       "      <td>6.66</td>\n",
       "      <td>6.66</td>\n",
       "      <td>196.00</td>\n",
       "      <td>4.9000</td>\n",
       "      <td>792.40</td>\n",
       "      <td>463.40</td>\n",
       "      <td>127.40</td>\n",
       "      <td>8.40</td>\n",
       "      <td>8.40</td>\n",
       "      <td>0.122500</td>\n",
       "      <td>19.8100</td>\n",
       "      <td>11.5850</td>\n",
       "      <td>3.1850</td>\n",
       "      <td>0.2100</td>\n",
       "      <td>0.2100</td>\n",
       "      <td>3203.56</td>\n",
       "      <td>1873.46</td>\n",
       "      <td>515.06</td>\n",
       "      <td>33.96</td>\n",
       "      <td>33.96</td>\n",
       "      <td>1095.61</td>\n",
       "      <td>301.21</td>\n",
       "      <td>19.86</td>\n",
       "      <td>19.86</td>\n",
       "      <td>82.81</td>\n",
       "      <td>5.46</td>\n",
       "      <td>5.46</td>\n",
       "      <td>0.36</td>\n",
       "      <td>0.36</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 741 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    年龄*年龄  年龄**天门冬氨酸氨基转换酶  年龄**丙氨酸氨基转换酶  年龄**碱性磷酸酶  年龄**r-谷氨酰基转换酶  年龄**总蛋白  \\\n",
       "id                                                                           \n",
       "1    1681         1023.36        947.10    4083.19         829.43  3152.08   \n",
       "2    1681         1007.37       1486.25    2755.61        3239.00  3256.63   \n",
       "3    2116          957.72        700.58    2929.74        1755.82  3966.58   \n",
       "4     484          329.78        232.98    1629.76         444.84  1561.56   \n",
       "5    2304          963.36        709.44    3637.92        1090.56  3746.40   \n",
       "\n",
       "     年龄*白蛋白  年龄**球蛋白  年龄*白球比例  年龄*甘油三酯  年龄*总胆固醇  年龄*高密度脂蛋白胆固醇  年龄*低密度脂蛋白胆固醇  \\\n",
       "id                                                                            \n",
       "1   2033.60  1118.48    74.62    53.71   181.63         56.17        108.65   \n",
       "2   1958.16  1298.47    61.91   115.21   166.46         38.13        107.83   \n",
       "3   2208.00  1758.58    57.96    45.54   189.98         75.44         92.46   \n",
       "4    968.44   593.12    35.86    23.32   151.58         31.46        110.88   \n",
       "5   2007.84  1738.56    55.20    46.56   257.76         60.96        175.20   \n",
       "\n",
       "     年龄*尿素    年龄*肌酐     年龄*尿酸  年龄*乙肝表面抗原  年龄*乙肝表面抗体  年龄*乙肝e抗原  年龄*乙肝e抗体  \\\n",
       "id                                                                        \n",
       "1   240.67  3167.25  14324.99       1.64     132.02      1.64     68.47   \n",
       "2   215.66  3571.92  19957.98       1.64     132.02      1.64     68.47   \n",
       "3   219.42  3596.74  20795.22       0.46       0.92      0.46     63.02   \n",
       "4    93.06  1352.12   8114.70       0.88      70.84      0.88     36.74   \n",
       "5   233.28  3704.64  16400.16       1.92     154.56      1.92     80.16   \n",
       "\n",
       "    年龄*乙肝核心抗体  年龄*白细胞计数  年龄*红细胞计数  年龄*血红蛋白  年龄*红细胞压积  年龄*红细胞平均体积  \\\n",
       "id                                                                 \n",
       "1       69.29    218.94    213.61   6810.1    19.639      3767.9   \n",
       "2       69.29    313.65    213.61   6396.0    18.696      3587.5   \n",
       "3       49.22    211.60    218.96   6844.8    20.148      4227.4   \n",
       "4       37.18    205.92     94.38   3014.0     8.866      2065.8   \n",
       "5       81.12    243.36    247.20   5088.0    16.992      3297.6   \n",
       "\n",
       "    年龄*红细胞平均血红蛋白量  年龄*红细胞平均血红蛋白浓度  年龄*红细胞体积分布宽度  年龄*血小板计数  年龄*血小板平均体积  \\\n",
       "id                                                                      \n",
       "1          1307.9         14227.0         524.8    6806.0       405.9   \n",
       "2          1225.9         14022.0         549.4   11357.0       377.2   \n",
       "3          1439.8         15640.0         598.0   11086.0       381.8   \n",
       "4           701.8          7480.0         277.2    5544.0       226.6   \n",
       "5           988.8         14352.0         796.8   15168.0       532.8   \n",
       "\n",
       "    年龄*血小板体积分布宽度  年龄*血小板比积  年龄*中性粒细胞%  年龄*淋巴细胞%  年龄*单核细胞%  年龄*嗜酸细胞%  年龄*嗜碱细胞%  \\\n",
       "id                                                                              \n",
       "1          713.4     6.724     2218.1    1402.2     266.5     192.7      24.6   \n",
       "2          422.3    10.660     2132.0    1504.7     237.8     192.7      32.8   \n",
       "3          763.6     9.154     2212.6    1853.8     354.2     147.2      36.8   \n",
       "4          237.6     5.720      917.4    1023.0     147.4     101.2      11.0   \n",
       "5          672.0    16.800     2716.8    1588.8     436.8      28.8      28.8   \n",
       "\n",
       "    *天门冬氨酸氨基转换酶**天门冬氨酸氨基转换酶  *天门冬氨酸氨基转换酶**丙氨酸氨基转换酶  *天门冬氨酸氨基转换酶**碱性磷酸酶  \\\n",
       "id                                                                       \n",
       "1                  623.0016               576.5760           2485.7664   \n",
       "2                  603.6849               890.6625           1651.3497   \n",
       "3                  433.4724               317.0886           1326.0258   \n",
       "4                  224.7001               158.7441           1110.4592   \n",
       "5                  402.8049               296.6346           1521.1053   \n",
       "\n",
       "    *天门冬氨酸氨基转换酶**r-谷氨酰基转换酶  *天门冬氨酸氨基转换酶**总蛋白  *天门冬氨酸氨基转换酶*白蛋白  \\\n",
       "id                                                              \n",
       "1                 504.9408         1918.9248        1238.0160   \n",
       "2                1941.0300         1951.5951        1173.4632   \n",
       "3                 794.6994         1795.3086         999.3600   \n",
       "4                 303.0978         1063.9902         659.8598   \n",
       "5                 455.9904         1566.4635         839.5281   \n",
       "\n",
       "    *天门冬氨酸氨基转换酶**球蛋白  *天门冬氨酸氨基转换酶*白球比例  *天门冬氨酸氨基转换酶*甘油三酯  *天门冬氨酸氨基转换酶*总胆固醇  \\\n",
       "id                                                                           \n",
       "1           680.9088           45.4272           32.6976          110.5728   \n",
       "2           778.1319           37.1007           69.0417           99.7542   \n",
       "3           795.9486           26.2332           20.6118           85.9866   \n",
       "4           404.1304           24.4337           15.8894          103.2811   \n",
       "5           726.9354           23.0805           19.4679          107.7759   \n",
       "\n",
       "    *天门冬氨酸氨基转换酶*高密度脂蛋白胆固醇  *天门冬氨酸氨基转换酶*低密度脂蛋白胆固醇     ...       \\\n",
       "id                                                   ...        \n",
       "1                 34.1952                66.1440     ...        \n",
       "2                 22.8501                64.6191     ...        \n",
       "3                 34.1448                41.8482     ...        \n",
       "4                 21.4357                75.5496     ...        \n",
       "5                 25.4889                73.2555     ...        \n",
       "\n",
       "    红细胞体积分布宽度*中性粒细胞%  红细胞体积分布宽度*淋巴细胞%  红细胞体积分布宽度*单核细胞%  红细胞体积分布宽度*嗜酸细胞%  \\\n",
       "id                                                                        \n",
       "1             692.48           437.76            83.20            60.16   \n",
       "2             696.80           491.78            77.72            62.98   \n",
       "3             625.30           523.90           100.10            41.60   \n",
       "4             525.42           585.90            84.42            57.96   \n",
       "5             939.56           549.46           151.06             9.96   \n",
       "\n",
       "    红细胞体积分布宽度*嗜碱细胞%  血小板计数*血小板计数  血小板计数*血小板平均体积  血小板计数*血小板体积分布宽度  血小板计数*血小板比积  \\\n",
       "id                                                                              \n",
       "1              7.68      27556.0         1643.4           2888.4       27.224   \n",
       "2             10.72      76729.0         2548.4           2853.1       72.020   \n",
       "3             10.40      58081.0         2000.3           4000.6       47.959   \n",
       "4              6.30      63504.0         2595.6           2721.6       65.520   \n",
       "5              9.96      99856.0         3507.6           4424.0      110.600   \n",
       "\n",
       "    血小板计数*中性粒细胞%  血小板计数*淋巴细胞%  血小板计数*单核细胞%  血小板计数*嗜酸细胞%  血小板计数*嗜碱细胞%  \\\n",
       "id                                                                     \n",
       "1         8980.6       5677.2       1079.0        780.2         99.6   \n",
       "2        14404.0      10165.9       1606.6       1301.9        221.6   \n",
       "3        11592.1       9712.3       1855.7        771.2        192.8   \n",
       "4        10508.4      11718.0       1688.4       1159.2        126.0   \n",
       "5        17885.6      10459.6       2875.6        189.6        189.6   \n",
       "\n",
       "    血小板平均体积*血小板平均体积  血小板平均体积*血小板体积分布宽度  血小板平均体积*血小板比积  血小板平均体积*中性粒细胞%  \\\n",
       "id                                                                      \n",
       "1             98.01             172.26         1.6236          535.59   \n",
       "2             84.64              94.76         2.3920          478.40   \n",
       "3             68.89             137.78         1.6517          399.23   \n",
       "4            106.09             111.24         2.6780          429.51   \n",
       "5            123.21             155.40         3.8850          628.26   \n",
       "\n",
       "    血小板平均体积*淋巴细胞%  血小板平均体积*单核细胞%  血小板平均体积*嗜酸细胞%  血小板平均体积*嗜碱细胞%  \\\n",
       "id                                                               \n",
       "1          338.58          64.35          46.53           5.94   \n",
       "2          337.64          53.36          43.24           7.36   \n",
       "3          334.49          63.91          26.56           6.64   \n",
       "4          478.95          69.01          47.38           5.15   \n",
       "5          367.41         101.01           6.66           6.66   \n",
       "\n",
       "    血小板体积分布宽度*血小板体积分布宽度  血小板体积分布宽度*血小板比积  血小板体积分布宽度*中性粒细胞%  血小板体积分布宽度*淋巴细胞%  \\\n",
       "id                                                                            \n",
       "1                302.76           2.8536            941.34           595.08   \n",
       "2                106.09           2.6780            535.60           378.01   \n",
       "3                275.56           3.3034            798.46           668.98   \n",
       "4                116.64           2.8080            450.36           502.20   \n",
       "5                196.00           4.9000            792.40           463.40   \n",
       "\n",
       "    血小板体积分布宽度*单核细胞%  血小板体积分布宽度*嗜酸细胞%  血小板体积分布宽度*嗜碱细胞%  血小板比积*血小板比积  \\\n",
       "id                                                                   \n",
       "1            113.10            81.78            10.44     0.026896   \n",
       "2             59.74            48.41             8.24     0.067600   \n",
       "3            127.82            53.12            13.28     0.039601   \n",
       "4             72.36            49.68             5.40     0.067600   \n",
       "5            127.40             8.40             8.40     0.122500   \n",
       "\n",
       "    血小板比积*中性粒细胞%  血小板比积*淋巴细胞%  血小板比积*单核细胞%  血小板比积*嗜酸细胞%  血小板比积*嗜碱细胞%  \\\n",
       "id                                                                     \n",
       "1         8.8724       5.6088       1.0660       0.7708       0.0984   \n",
       "2        13.5200       9.5420       1.5080       1.2220       0.2080   \n",
       "3         9.5719       8.0197       1.5323       0.6368       0.1592   \n",
       "4        10.8420      12.0900       1.7420       1.1960       0.1300   \n",
       "5        19.8100      11.5850       3.1850       0.2100       0.2100   \n",
       "\n",
       "    中性粒细胞%*中性粒细胞%  中性粒细胞%*淋巴细胞%  中性粒细胞%*单核细胞%  中性粒细胞%*嗜酸细胞%  中性粒细胞%*嗜碱细胞%  \\\n",
       "id                                                                          \n",
       "1         2926.81       1850.22        351.65        254.27         32.46   \n",
       "2         2704.00       1908.40        301.60        244.40         41.60   \n",
       "3         2313.61       1938.43        370.37        153.92         38.48   \n",
       "4         1738.89       1939.05        279.39        191.82         20.85   \n",
       "5         3203.56       1873.46        515.06         33.96         33.96   \n",
       "\n",
       "    淋巴细胞%*淋巴细胞%  淋巴细胞%*单核细胞%  淋巴细胞%*嗜酸细胞%  淋巴细胞%*嗜碱细胞%  单核细胞%*单核细胞%  \\\n",
       "id                                                                    \n",
       "1       1169.64       222.30       160.74        20.52        42.25   \n",
       "2       1346.89       212.86       172.49        29.36        33.64   \n",
       "3       1624.09       310.31       128.96        32.24        59.29   \n",
       "4       2162.25       311.55       213.90        23.25        44.89   \n",
       "5       1095.61       301.21        19.86        19.86        82.81   \n",
       "\n",
       "    单核细胞%*嗜酸细胞%  单核细胞%*嗜碱细胞%  嗜酸细胞%*嗜酸细胞%  嗜酸细胞%*嗜碱细胞%  嗜碱细胞%*嗜碱细胞%  \n",
       "id                                                                   \n",
       "1         30.55         3.90        22.09         2.82         0.36  \n",
       "2         27.26         4.64        22.09         3.76         0.64  \n",
       "3         24.64         6.16        10.24         2.56         0.64  \n",
       "4         30.82         3.35        21.16         2.30         0.25  \n",
       "5          5.46         5.46         0.36         0.36         0.36  \n",
       "\n",
       "[5 rows x 741 columns]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# rank特征# 数值型数据 # 两两相乘\n",
    "df_dtypes = combined_copy.dtypes\n",
    "float_features =list(df_dtypes[df_dtypes!='object'].index)\n",
    "combined_rank = pd.DataFrame(index=combined_copy.index)\n",
    "combined_ratio = pd.DataFrame(index=combined_copy.index)\n",
    "combined_mul = pd.DataFrame(index=combined_copy.index)\n",
    "for feature in float_features:\n",
    "    combined_rank['r'+feature] = combined_copy[feature].rank(method='max')/float(len(combined_copy))\n",
    "# 两两相除的特征\n",
    "# 两两相乘的特征\n",
    "for i,feature1 in enumerate(float_features):\n",
    "    if len(float_features[i+1:])>0:\n",
    "        for feature2 in float_features[i+1:]:\n",
    "            combined_ratio[feature1 + '_' + feature2] = combined_copy[feature1]/combined_copy[feature2]\n",
    "    for feature2 in float_features[i:]:\n",
    "            combined_mul[feature1 + '*' + feature2] = combined_copy[feature1]*combined_copy[feature2]\n",
    "combined_ratio.fillna(combined_ratio.median(axis=0),inplace=True)\n",
    "combined_ratio[combined_ratio == np.inf] = 1e6\n",
    "# print(combined_ratio.head())\n",
    "combined_mul.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# combined_ratio.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# (pd.to_datetime(combined['体检日期']) - parse('2017-10-09')).dt.days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipykernel\\__main__.py:12: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别</th>\n",
       "      <th>年龄</th>\n",
       "      <th>体检日期</th>\n",
       "      <th>*天门冬氨酸氨基转换酶</th>\n",
       "      <th>*丙氨酸氨基转换酶</th>\n",
       "      <th>*碱性磷酸酶</th>\n",
       "      <th>*r-谷氨酰基转换酶</th>\n",
       "      <th>*总蛋白</th>\n",
       "      <th>白蛋白</th>\n",
       "      <th>*球蛋白</th>\n",
       "      <th>白球比例</th>\n",
       "      <th>甘油三酯</th>\n",
       "      <th>总胆固醇</th>\n",
       "      <th>高密度脂蛋白胆固醇</th>\n",
       "      <th>低密度脂蛋白胆固醇</th>\n",
       "      <th>尿素</th>\n",
       "      <th>肌酐</th>\n",
       "      <th>尿酸</th>\n",
       "      <th>乙肝表面抗原</th>\n",
       "      <th>乙肝表面抗体</th>\n",
       "      <th>乙肝e抗原</th>\n",
       "      <th>乙肝e抗体</th>\n",
       "      <th>乙肝核心抗体</th>\n",
       "      <th>白细胞计数</th>\n",
       "      <th>红细胞计数</th>\n",
       "      <th>血红蛋白</th>\n",
       "      <th>红细胞压积</th>\n",
       "      <th>红细胞平均体积</th>\n",
       "      <th>红细胞平均血红蛋白量</th>\n",
       "      <th>红细胞平均血红蛋白浓度</th>\n",
       "      <th>红细胞体积分布宽度</th>\n",
       "      <th>血小板计数</th>\n",
       "      <th>血小板平均体积</th>\n",
       "      <th>血小板体积分布宽度</th>\n",
       "      <th>血小板比积</th>\n",
       "      <th>中性粒细胞%</th>\n",
       "      <th>淋巴细胞%</th>\n",
       "      <th>单核细胞%</th>\n",
       "      <th>嗜酸细胞%</th>\n",
       "      <th>嗜碱细胞%</th>\n",
       "      <th>有无蛋白指标</th>\n",
       "      <th>有无固醇指标</th>\n",
       "      <th>有无血指标</th>\n",
       "      <th>有无细胞指标</th>\n",
       "      <th>有无酶指标</th>\n",
       "      <th>有无尿指标</th>\n",
       "      <th>有无肝指标</th>\n",
       "      <th>缺失值数量</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>12/10/2017</td>\n",
       "      <td>24.96</td>\n",
       "      <td>23.10</td>\n",
       "      <td>99.59</td>\n",
       "      <td>20.23</td>\n",
       "      <td>76.88</td>\n",
       "      <td>49.60</td>\n",
       "      <td>27.28</td>\n",
       "      <td>1.82</td>\n",
       "      <td>1.31</td>\n",
       "      <td>4.43</td>\n",
       "      <td>1.37</td>\n",
       "      <td>2.65</td>\n",
       "      <td>5.87</td>\n",
       "      <td>77.25</td>\n",
       "      <td>349.39</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.34</td>\n",
       "      <td>5.21</td>\n",
       "      <td>166.1</td>\n",
       "      <td>0.479</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>347.0</td>\n",
       "      <td>12.8</td>\n",
       "      <td>166.0</td>\n",
       "      <td>9.9</td>\n",
       "      <td>17.4</td>\n",
       "      <td>0.164</td>\n",
       "      <td>54.1</td>\n",
       "      <td>34.2</td>\n",
       "      <td>6.5</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>19/10/2017</td>\n",
       "      <td>24.57</td>\n",
       "      <td>36.25</td>\n",
       "      <td>67.21</td>\n",
       "      <td>79.00</td>\n",
       "      <td>79.43</td>\n",
       "      <td>47.76</td>\n",
       "      <td>31.67</td>\n",
       "      <td>1.51</td>\n",
       "      <td>2.81</td>\n",
       "      <td>4.06</td>\n",
       "      <td>0.93</td>\n",
       "      <td>2.63</td>\n",
       "      <td>5.26</td>\n",
       "      <td>87.12</td>\n",
       "      <td>486.78</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.65</td>\n",
       "      <td>5.21</td>\n",
       "      <td>156.0</td>\n",
       "      <td>0.456</td>\n",
       "      <td>87.5</td>\n",
       "      <td>29.9</td>\n",
       "      <td>342.0</td>\n",
       "      <td>13.4</td>\n",
       "      <td>277.0</td>\n",
       "      <td>9.2</td>\n",
       "      <td>10.3</td>\n",
       "      <td>0.260</td>\n",
       "      <td>52.0</td>\n",
       "      <td>36.7</td>\n",
       "      <td>5.8</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>46</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.82</td>\n",
       "      <td>15.23</td>\n",
       "      <td>63.69</td>\n",
       "      <td>38.17</td>\n",
       "      <td>86.23</td>\n",
       "      <td>48.00</td>\n",
       "      <td>38.23</td>\n",
       "      <td>1.26</td>\n",
       "      <td>0.99</td>\n",
       "      <td>4.13</td>\n",
       "      <td>1.64</td>\n",
       "      <td>2.01</td>\n",
       "      <td>4.77</td>\n",
       "      <td>78.19</td>\n",
       "      <td>452.07</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.01</td>\n",
       "      <td>1.37</td>\n",
       "      <td>1.07</td>\n",
       "      <td>4.60</td>\n",
       "      <td>4.76</td>\n",
       "      <td>148.8</td>\n",
       "      <td>0.438</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.3</td>\n",
       "      <td>340.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>241.0</td>\n",
       "      <td>8.3</td>\n",
       "      <td>16.6</td>\n",
       "      <td>0.199</td>\n",
       "      <td>48.1</td>\n",
       "      <td>40.3</td>\n",
       "      <td>7.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "      <td>25/10/2017</td>\n",
       "      <td>14.99</td>\n",
       "      <td>10.59</td>\n",
       "      <td>74.08</td>\n",
       "      <td>20.22</td>\n",
       "      <td>70.98</td>\n",
       "      <td>44.02</td>\n",
       "      <td>26.96</td>\n",
       "      <td>1.63</td>\n",
       "      <td>1.06</td>\n",
       "      <td>6.89</td>\n",
       "      <td>1.43</td>\n",
       "      <td>5.04</td>\n",
       "      <td>4.23</td>\n",
       "      <td>61.46</td>\n",
       "      <td>368.85</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.36</td>\n",
       "      <td>4.29</td>\n",
       "      <td>137.0</td>\n",
       "      <td>0.403</td>\n",
       "      <td>93.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>340.0</td>\n",
       "      <td>12.6</td>\n",
       "      <td>252.0</td>\n",
       "      <td>10.3</td>\n",
       "      <td>10.8</td>\n",
       "      <td>0.260</td>\n",
       "      <td>41.7</td>\n",
       "      <td>46.5</td>\n",
       "      <td>6.7</td>\n",
       "      <td>4.6</td>\n",
       "      <td>0.5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.07</td>\n",
       "      <td>14.78</td>\n",
       "      <td>75.79</td>\n",
       "      <td>22.72</td>\n",
       "      <td>78.05</td>\n",
       "      <td>41.83</td>\n",
       "      <td>36.22</td>\n",
       "      <td>1.15</td>\n",
       "      <td>0.97</td>\n",
       "      <td>5.37</td>\n",
       "      <td>1.27</td>\n",
       "      <td>3.65</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.07</td>\n",
       "      <td>5.15</td>\n",
       "      <td>106.0</td>\n",
       "      <td>0.354</td>\n",
       "      <td>68.7</td>\n",
       "      <td>20.6</td>\n",
       "      <td>299.0</td>\n",
       "      <td>16.6</td>\n",
       "      <td>316.0</td>\n",
       "      <td>11.1</td>\n",
       "      <td>14.0</td>\n",
       "      <td>0.350</td>\n",
       "      <td>56.6</td>\n",
       "      <td>33.1</td>\n",
       "      <td>9.1</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别  年龄        体检日期  *天门冬氨酸氨基转换酶  *丙氨酸氨基转换酶  *碱性磷酸酶  *r-谷氨酰基转换酶   *总蛋白  \\\n",
       "id                                                                          \n",
       "1    1  41  12/10/2017        24.96      23.10   99.59       20.23  76.88   \n",
       "2    1  41  19/10/2017        24.57      36.25   67.21       79.00  79.43   \n",
       "3    1  46  26/10/2017        20.82      15.23   63.69       38.17  86.23   \n",
       "4    0  22  25/10/2017        14.99      10.59   74.08       20.22  70.98   \n",
       "5    0  48  26/10/2017        20.07      14.78   75.79       22.72  78.05   \n",
       "\n",
       "      白蛋白   *球蛋白  白球比例  甘油三酯  总胆固醇  高密度脂蛋白胆固醇  低密度脂蛋白胆固醇    尿素     肌酐      尿酸  \\\n",
       "id                                                                              \n",
       "1   49.60  27.28  1.82  1.31  4.43       1.37       2.65  5.87  77.25  349.39   \n",
       "2   47.76  31.67  1.51  2.81  4.06       0.93       2.63  5.26  87.12  486.78   \n",
       "3   48.00  38.23  1.26  0.99  4.13       1.64       2.01  4.77  78.19  452.07   \n",
       "4   44.02  26.96  1.63  1.06  6.89       1.43       5.04  4.23  61.46  368.85   \n",
       "5   41.83  36.22  1.15  0.97  5.37       1.27       3.65   NaN    NaN     NaN   \n",
       "\n",
       "    乙肝表面抗原  乙肝表面抗体  乙肝e抗原  乙肝e抗体  乙肝核心抗体  白细胞计数  红细胞计数   血红蛋白  红细胞压积  红细胞平均体积  \\\n",
       "id                                                                              \n",
       "1      NaN     NaN    NaN    NaN     NaN   5.34   5.21  166.1  0.479     91.9   \n",
       "2      NaN     NaN    NaN    NaN     NaN   7.65   5.21  156.0  0.456     87.5   \n",
       "3     0.01    0.02   0.01   1.37    1.07   4.60   4.76  148.8  0.438     91.9   \n",
       "4      NaN     NaN    NaN    NaN     NaN   9.36   4.29  137.0  0.403     93.9   \n",
       "5      NaN     NaN    NaN    NaN     NaN   5.07   5.15  106.0  0.354     68.7   \n",
       "\n",
       "    红细胞平均血红蛋白量  红细胞平均血红蛋白浓度  红细胞体积分布宽度  血小板计数  血小板平均体积  血小板体积分布宽度  血小板比积  \\\n",
       "id                                                                         \n",
       "1         31.9        347.0       12.8  166.0      9.9       17.4  0.164   \n",
       "2         29.9        342.0       13.4  277.0      9.2       10.3  0.260   \n",
       "3         31.3        340.0       13.0  241.0      8.3       16.6  0.199   \n",
       "4         31.9        340.0       12.6  252.0     10.3       10.8  0.260   \n",
       "5         20.6        299.0       16.6  316.0     11.1       14.0  0.350   \n",
       "\n",
       "    中性粒细胞%  淋巴细胞%  单核细胞%  嗜酸细胞%  嗜碱细胞%  有无蛋白指标  有无固醇指标  有无血指标  有无细胞指标  有无酶指标  \\\n",
       "id                                                                             \n",
       "1     54.1   34.2    6.5    4.7    0.6       1       1      1       1      1   \n",
       "2     52.0   36.7    5.8    4.7    0.8       1       1      1       1      1   \n",
       "3     48.1   40.3    7.7    3.2    0.8       1       1      1       1      1   \n",
       "4     41.7   46.5    6.7    4.6    0.5       1       1      1       1      1   \n",
       "5     56.6   33.1    9.1    0.6    0.6       1       1      1       1      1   \n",
       "\n",
       "    有无尿指标  有无肝指标  缺失值数量  \n",
       "id                       \n",
       "1       1      0      5  \n",
       "2       1      0      5  \n",
       "3       1      1      0  \n",
       "4       1      0      5  \n",
       "5       0      0      8  "
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 判断有无指标\n",
    "combined['有无蛋白指标'] = np.where(combined['白蛋白'].isnull(),0,1)\n",
    "combined['有无固醇指标'] = np.where(combined['甘油三酯'].isnull(),0,1)\n",
    "combined['有无血指标'] = np.where(combined['血红蛋白'].isnull(),0,1)\n",
    "combined['有无细胞指标'] = np.where(combined['淋巴细胞%'].isnull(),0,1)\n",
    "combined['有无酶指标'] = np.where(combined['*碱性磷酸酶'].isnull(),0,1)\n",
    "combined['有无尿指标'] = np.where(combined['尿素'].isnull(),0,1)\n",
    "combined['有无肝指标'] = np.where(combined['乙肝表面抗原'].isnull(),0,1)\n",
    "# 统计确实值的数量\n",
    "combined['缺失值数量'] = combined.apply(lambda x:combined.shape[1]-x.count(),axis=1)\n",
    "# 对性别热编码\n",
    "combined['性别'][combined['性别']== '??'] = '女'\n",
    "combined['性别'] = combined['性别'].map({'男':1, '女':0})\n",
    "# combined['体检日期'] = (pd.to_datetime(combined['体检日期']) - parse('2017-10-09')).dt.days\n",
    "combined.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# # 按照每天血糖的平均值排序\n",
    "# day_mean = combined.groupby('体检日期').agg({'血糖':np.mean})\n",
    "# time = day_mean.sort_values('血糖').index\n",
    "# time_mapping = dict((v,i) for i,v in enumerate(time))\n",
    "# combined['体检日期'] = combined['体检日期'].map(time_mapping)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别</th>\n",
       "      <th>年龄</th>\n",
       "      <th>体检日期</th>\n",
       "      <th>*天门冬氨酸氨基转换酶</th>\n",
       "      <th>*丙氨酸氨基转换酶</th>\n",
       "      <th>*碱性磷酸酶</th>\n",
       "      <th>*r-谷氨酰基转换酶</th>\n",
       "      <th>*总蛋白</th>\n",
       "      <th>白蛋白</th>\n",
       "      <th>*球蛋白</th>\n",
       "      <th>白球比例</th>\n",
       "      <th>甘油三酯</th>\n",
       "      <th>总胆固醇</th>\n",
       "      <th>高密度脂蛋白胆固醇</th>\n",
       "      <th>低密度脂蛋白胆固醇</th>\n",
       "      <th>尿素</th>\n",
       "      <th>肌酐</th>\n",
       "      <th>尿酸</th>\n",
       "      <th>乙肝表面抗原</th>\n",
       "      <th>乙肝表面抗体</th>\n",
       "      <th>乙肝e抗原</th>\n",
       "      <th>乙肝e抗体</th>\n",
       "      <th>乙肝核心抗体</th>\n",
       "      <th>白细胞计数</th>\n",
       "      <th>红细胞计数</th>\n",
       "      <th>血红蛋白</th>\n",
       "      <th>红细胞压积</th>\n",
       "      <th>红细胞平均体积</th>\n",
       "      <th>红细胞平均血红蛋白量</th>\n",
       "      <th>红细胞平均血红蛋白浓度</th>\n",
       "      <th>红细胞体积分布宽度</th>\n",
       "      <th>血小板计数</th>\n",
       "      <th>血小板平均体积</th>\n",
       "      <th>血小板体积分布宽度</th>\n",
       "      <th>血小板比积</th>\n",
       "      <th>中性粒细胞%</th>\n",
       "      <th>淋巴细胞%</th>\n",
       "      <th>单核细胞%</th>\n",
       "      <th>嗜酸细胞%</th>\n",
       "      <th>嗜碱细胞%</th>\n",
       "      <th>有无蛋白指标</th>\n",
       "      <th>有无固醇指标</th>\n",
       "      <th>有无血指标</th>\n",
       "      <th>有无细胞指标</th>\n",
       "      <th>有无酶指标</th>\n",
       "      <th>有无尿指标</th>\n",
       "      <th>有无肝指标</th>\n",
       "      <th>缺失值数量</th>\n",
       "      <th>酶_mean</th>\n",
       "      <th>酶_max</th>\n",
       "      <th>酶_min</th>\n",
       "      <th>酶_std</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>12/10/2017</td>\n",
       "      <td>24.96</td>\n",
       "      <td>23.10</td>\n",
       "      <td>99.59</td>\n",
       "      <td>20.23</td>\n",
       "      <td>76.88</td>\n",
       "      <td>49.60</td>\n",
       "      <td>27.28</td>\n",
       "      <td>1.82</td>\n",
       "      <td>1.31</td>\n",
       "      <td>4.43</td>\n",
       "      <td>1.37</td>\n",
       "      <td>2.65</td>\n",
       "      <td>5.87</td>\n",
       "      <td>77.25</td>\n",
       "      <td>349.39</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.34</td>\n",
       "      <td>5.21</td>\n",
       "      <td>166.1</td>\n",
       "      <td>0.479</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>347.0</td>\n",
       "      <td>12.8</td>\n",
       "      <td>166.0</td>\n",
       "      <td>9.9</td>\n",
       "      <td>17.4</td>\n",
       "      <td>0.164</td>\n",
       "      <td>54.1</td>\n",
       "      <td>34.2</td>\n",
       "      <td>6.5</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>41.9700</td>\n",
       "      <td>99.59</td>\n",
       "      <td>20.23</td>\n",
       "      <td>38.462575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>19/10/2017</td>\n",
       "      <td>24.57</td>\n",
       "      <td>36.25</td>\n",
       "      <td>67.21</td>\n",
       "      <td>79.00</td>\n",
       "      <td>79.43</td>\n",
       "      <td>47.76</td>\n",
       "      <td>31.67</td>\n",
       "      <td>1.51</td>\n",
       "      <td>2.81</td>\n",
       "      <td>4.06</td>\n",
       "      <td>0.93</td>\n",
       "      <td>2.63</td>\n",
       "      <td>5.26</td>\n",
       "      <td>87.12</td>\n",
       "      <td>486.78</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.65</td>\n",
       "      <td>5.21</td>\n",
       "      <td>156.0</td>\n",
       "      <td>0.456</td>\n",
       "      <td>87.5</td>\n",
       "      <td>29.9</td>\n",
       "      <td>342.0</td>\n",
       "      <td>13.4</td>\n",
       "      <td>277.0</td>\n",
       "      <td>9.2</td>\n",
       "      <td>10.3</td>\n",
       "      <td>0.260</td>\n",
       "      <td>52.0</td>\n",
       "      <td>36.7</td>\n",
       "      <td>5.8</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>51.7575</td>\n",
       "      <td>79.00</td>\n",
       "      <td>24.57</td>\n",
       "      <td>25.564143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>46</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.82</td>\n",
       "      <td>15.23</td>\n",
       "      <td>63.69</td>\n",
       "      <td>38.17</td>\n",
       "      <td>86.23</td>\n",
       "      <td>48.00</td>\n",
       "      <td>38.23</td>\n",
       "      <td>1.26</td>\n",
       "      <td>0.99</td>\n",
       "      <td>4.13</td>\n",
       "      <td>1.64</td>\n",
       "      <td>2.01</td>\n",
       "      <td>4.77</td>\n",
       "      <td>78.19</td>\n",
       "      <td>452.07</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.01</td>\n",
       "      <td>1.37</td>\n",
       "      <td>1.07</td>\n",
       "      <td>4.60</td>\n",
       "      <td>4.76</td>\n",
       "      <td>148.8</td>\n",
       "      <td>0.438</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.3</td>\n",
       "      <td>340.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>241.0</td>\n",
       "      <td>8.3</td>\n",
       "      <td>16.6</td>\n",
       "      <td>0.199</td>\n",
       "      <td>48.1</td>\n",
       "      <td>40.3</td>\n",
       "      <td>7.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>34.4775</td>\n",
       "      <td>63.69</td>\n",
       "      <td>15.23</td>\n",
       "      <td>21.786833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "      <td>25/10/2017</td>\n",
       "      <td>14.99</td>\n",
       "      <td>10.59</td>\n",
       "      <td>74.08</td>\n",
       "      <td>20.22</td>\n",
       "      <td>70.98</td>\n",
       "      <td>44.02</td>\n",
       "      <td>26.96</td>\n",
       "      <td>1.63</td>\n",
       "      <td>1.06</td>\n",
       "      <td>6.89</td>\n",
       "      <td>1.43</td>\n",
       "      <td>5.04</td>\n",
       "      <td>4.23</td>\n",
       "      <td>61.46</td>\n",
       "      <td>368.85</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.36</td>\n",
       "      <td>4.29</td>\n",
       "      <td>137.0</td>\n",
       "      <td>0.403</td>\n",
       "      <td>93.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>340.0</td>\n",
       "      <td>12.6</td>\n",
       "      <td>252.0</td>\n",
       "      <td>10.3</td>\n",
       "      <td>10.8</td>\n",
       "      <td>0.260</td>\n",
       "      <td>41.7</td>\n",
       "      <td>46.5</td>\n",
       "      <td>6.7</td>\n",
       "      <td>4.6</td>\n",
       "      <td>0.5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>29.9700</td>\n",
       "      <td>74.08</td>\n",
       "      <td>10.59</td>\n",
       "      <td>29.668948</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.07</td>\n",
       "      <td>14.78</td>\n",
       "      <td>75.79</td>\n",
       "      <td>22.72</td>\n",
       "      <td>78.05</td>\n",
       "      <td>41.83</td>\n",
       "      <td>36.22</td>\n",
       "      <td>1.15</td>\n",
       "      <td>0.97</td>\n",
       "      <td>5.37</td>\n",
       "      <td>1.27</td>\n",
       "      <td>3.65</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.07</td>\n",
       "      <td>5.15</td>\n",
       "      <td>106.0</td>\n",
       "      <td>0.354</td>\n",
       "      <td>68.7</td>\n",
       "      <td>20.6</td>\n",
       "      <td>299.0</td>\n",
       "      <td>16.6</td>\n",
       "      <td>316.0</td>\n",
       "      <td>11.1</td>\n",
       "      <td>14.0</td>\n",
       "      <td>0.350</td>\n",
       "      <td>56.6</td>\n",
       "      <td>33.1</td>\n",
       "      <td>9.1</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>33.3400</td>\n",
       "      <td>75.79</td>\n",
       "      <td>14.78</td>\n",
       "      <td>28.491832</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别  年龄        体检日期  *天门冬氨酸氨基转换酶  *丙氨酸氨基转换酶  *碱性磷酸酶  *r-谷氨酰基转换酶   *总蛋白  \\\n",
       "id                                                                          \n",
       "1    1  41  12/10/2017        24.96      23.10   99.59       20.23  76.88   \n",
       "2    1  41  19/10/2017        24.57      36.25   67.21       79.00  79.43   \n",
       "3    1  46  26/10/2017        20.82      15.23   63.69       38.17  86.23   \n",
       "4    0  22  25/10/2017        14.99      10.59   74.08       20.22  70.98   \n",
       "5    0  48  26/10/2017        20.07      14.78   75.79       22.72  78.05   \n",
       "\n",
       "      白蛋白   *球蛋白  白球比例  甘油三酯  总胆固醇  高密度脂蛋白胆固醇  低密度脂蛋白胆固醇    尿素     肌酐      尿酸  \\\n",
       "id                                                                              \n",
       "1   49.60  27.28  1.82  1.31  4.43       1.37       2.65  5.87  77.25  349.39   \n",
       "2   47.76  31.67  1.51  2.81  4.06       0.93       2.63  5.26  87.12  486.78   \n",
       "3   48.00  38.23  1.26  0.99  4.13       1.64       2.01  4.77  78.19  452.07   \n",
       "4   44.02  26.96  1.63  1.06  6.89       1.43       5.04  4.23  61.46  368.85   \n",
       "5   41.83  36.22  1.15  0.97  5.37       1.27       3.65   NaN    NaN     NaN   \n",
       "\n",
       "    乙肝表面抗原  乙肝表面抗体  乙肝e抗原  乙肝e抗体  乙肝核心抗体  白细胞计数  红细胞计数   血红蛋白  红细胞压积  红细胞平均体积  \\\n",
       "id                                                                              \n",
       "1      NaN     NaN    NaN    NaN     NaN   5.34   5.21  166.1  0.479     91.9   \n",
       "2      NaN     NaN    NaN    NaN     NaN   7.65   5.21  156.0  0.456     87.5   \n",
       "3     0.01    0.02   0.01   1.37    1.07   4.60   4.76  148.8  0.438     91.9   \n",
       "4      NaN     NaN    NaN    NaN     NaN   9.36   4.29  137.0  0.403     93.9   \n",
       "5      NaN     NaN    NaN    NaN     NaN   5.07   5.15  106.0  0.354     68.7   \n",
       "\n",
       "    红细胞平均血红蛋白量  红细胞平均血红蛋白浓度  红细胞体积分布宽度  血小板计数  血小板平均体积  血小板体积分布宽度  血小板比积  \\\n",
       "id                                                                         \n",
       "1         31.9        347.0       12.8  166.0      9.9       17.4  0.164   \n",
       "2         29.9        342.0       13.4  277.0      9.2       10.3  0.260   \n",
       "3         31.3        340.0       13.0  241.0      8.3       16.6  0.199   \n",
       "4         31.9        340.0       12.6  252.0     10.3       10.8  0.260   \n",
       "5         20.6        299.0       16.6  316.0     11.1       14.0  0.350   \n",
       "\n",
       "    中性粒细胞%  淋巴细胞%  单核细胞%  嗜酸细胞%  嗜碱细胞%  有无蛋白指标  有无固醇指标  有无血指标  有无细胞指标  有无酶指标  \\\n",
       "id                                                                             \n",
       "1     54.1   34.2    6.5    4.7    0.6       1       1      1       1      1   \n",
       "2     52.0   36.7    5.8    4.7    0.8       1       1      1       1      1   \n",
       "3     48.1   40.3    7.7    3.2    0.8       1       1      1       1      1   \n",
       "4     41.7   46.5    6.7    4.6    0.5       1       1      1       1      1   \n",
       "5     56.6   33.1    9.1    0.6    0.6       1       1      1       1      1   \n",
       "\n",
       "    有无尿指标  有无肝指标  缺失值数量   酶_mean  酶_max  酶_min      酶_std  \n",
       "id                                                         \n",
       "1       1      0      5  41.9700  99.59  20.23  38.462575  \n",
       "2       1      0      5  51.7575  79.00  24.57  25.564143  \n",
       "3       1      1      0  34.4775  63.69  15.23  21.786833  \n",
       "4       1      0      5  29.9700  74.08  10.59  29.668948  \n",
       "5       0      0      8  33.3400  75.79  14.78  28.491832  "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 部分特征的统计特征\n",
    "combined['酶_mean'] = combined.loc[:,'*天门冬氨酸氨基转换酶':'*r-谷氨酰基转换酶'].mean(axis=1)\n",
    "combined['酶_max'] = combined.loc[:,'*天门冬氨酸氨基转换酶':'*r-谷氨酰基转换酶'].max(axis=1)\n",
    "combined['酶_min'] = combined.loc[:,'*天门冬氨酸氨基转换酶':'*r-谷氨酰基转换酶'].min(axis=1)\n",
    "combined['酶_std'] = combined.loc[:,'*天门冬氨酸氨基转换酶':'*r-谷氨酰基转换酶'].std(axis=1)\n",
    "# combined['固醇高低比'] = combined['高密度脂蛋白胆固醇']/combined['低密度脂蛋白胆固醇']\n",
    "# combined['尿素尿酸比'] = combined['尿酸']/combined['尿素']\n",
    "# combined['白红细胞和'] = combined['白细胞计数'] + combined['红细胞计数'] \n",
    "# combined['白红细胞比'] = combined['白细胞计数'] / combined['红细胞计数']\n",
    "combined.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别</th>\n",
       "      <th>年龄</th>\n",
       "      <th>体检日期</th>\n",
       "      <th>*天门冬氨酸氨基转换酶</th>\n",
       "      <th>*丙氨酸氨基转换酶</th>\n",
       "      <th>*碱性磷酸酶</th>\n",
       "      <th>*r-谷氨酰基转换酶</th>\n",
       "      <th>*总蛋白</th>\n",
       "      <th>白蛋白</th>\n",
       "      <th>*球蛋白</th>\n",
       "      <th>白球比例</th>\n",
       "      <th>甘油三酯</th>\n",
       "      <th>总胆固醇</th>\n",
       "      <th>高密度脂蛋白胆固醇</th>\n",
       "      <th>低密度脂蛋白胆固醇</th>\n",
       "      <th>尿素</th>\n",
       "      <th>肌酐</th>\n",
       "      <th>尿酸</th>\n",
       "      <th>乙肝表面抗原</th>\n",
       "      <th>乙肝表面抗体</th>\n",
       "      <th>乙肝e抗原</th>\n",
       "      <th>乙肝e抗体</th>\n",
       "      <th>乙肝核心抗体</th>\n",
       "      <th>白细胞计数</th>\n",
       "      <th>红细胞计数</th>\n",
       "      <th>血红蛋白</th>\n",
       "      <th>红细胞压积</th>\n",
       "      <th>红细胞平均体积</th>\n",
       "      <th>红细胞平均血红蛋白量</th>\n",
       "      <th>红细胞平均血红蛋白浓度</th>\n",
       "      <th>红细胞体积分布宽度</th>\n",
       "      <th>血小板计数</th>\n",
       "      <th>血小板平均体积</th>\n",
       "      <th>血小板体积分布宽度</th>\n",
       "      <th>血小板比积</th>\n",
       "      <th>中性粒细胞%</th>\n",
       "      <th>淋巴细胞%</th>\n",
       "      <th>单核细胞%</th>\n",
       "      <th>嗜酸细胞%</th>\n",
       "      <th>嗜碱细胞%</th>\n",
       "      <th>有无蛋白指标</th>\n",
       "      <th>有无固醇指标</th>\n",
       "      <th>有无血指标</th>\n",
       "      <th>有无细胞指标</th>\n",
       "      <th>有无酶指标</th>\n",
       "      <th>有无尿指标</th>\n",
       "      <th>有无肝指标</th>\n",
       "      <th>缺失值数量</th>\n",
       "      <th>酶_mean</th>\n",
       "      <th>酶_max</th>\n",
       "      <th>酶_min</th>\n",
       "      <th>酶_std</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>12/10/2017</td>\n",
       "      <td>24.96</td>\n",
       "      <td>23.10</td>\n",
       "      <td>99.59</td>\n",
       "      <td>20.23</td>\n",
       "      <td>76.88</td>\n",
       "      <td>49.60</td>\n",
       "      <td>27.28</td>\n",
       "      <td>1.82</td>\n",
       "      <td>1.31</td>\n",
       "      <td>4.43</td>\n",
       "      <td>1.37</td>\n",
       "      <td>2.65</td>\n",
       "      <td>5.87</td>\n",
       "      <td>77.25</td>\n",
       "      <td>349.39</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>5.34</td>\n",
       "      <td>5.21</td>\n",
       "      <td>166.1</td>\n",
       "      <td>0.479</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>347.0</td>\n",
       "      <td>12.8</td>\n",
       "      <td>166.0</td>\n",
       "      <td>9.9</td>\n",
       "      <td>17.4</td>\n",
       "      <td>0.164</td>\n",
       "      <td>54.1</td>\n",
       "      <td>34.2</td>\n",
       "      <td>6.5</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>41.9700</td>\n",
       "      <td>99.59</td>\n",
       "      <td>20.23</td>\n",
       "      <td>38.462575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>19/10/2017</td>\n",
       "      <td>24.57</td>\n",
       "      <td>36.25</td>\n",
       "      <td>67.21</td>\n",
       "      <td>79.00</td>\n",
       "      <td>79.43</td>\n",
       "      <td>47.76</td>\n",
       "      <td>31.67</td>\n",
       "      <td>1.51</td>\n",
       "      <td>2.81</td>\n",
       "      <td>4.06</td>\n",
       "      <td>0.93</td>\n",
       "      <td>2.63</td>\n",
       "      <td>5.26</td>\n",
       "      <td>87.12</td>\n",
       "      <td>486.78</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>7.65</td>\n",
       "      <td>5.21</td>\n",
       "      <td>156.0</td>\n",
       "      <td>0.456</td>\n",
       "      <td>87.5</td>\n",
       "      <td>29.9</td>\n",
       "      <td>342.0</td>\n",
       "      <td>13.4</td>\n",
       "      <td>277.0</td>\n",
       "      <td>9.2</td>\n",
       "      <td>10.3</td>\n",
       "      <td>0.260</td>\n",
       "      <td>52.0</td>\n",
       "      <td>36.7</td>\n",
       "      <td>5.8</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>51.7575</td>\n",
       "      <td>79.00</td>\n",
       "      <td>24.57</td>\n",
       "      <td>25.564143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>46</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.82</td>\n",
       "      <td>15.23</td>\n",
       "      <td>63.69</td>\n",
       "      <td>38.17</td>\n",
       "      <td>86.23</td>\n",
       "      <td>48.00</td>\n",
       "      <td>38.23</td>\n",
       "      <td>1.26</td>\n",
       "      <td>0.99</td>\n",
       "      <td>4.13</td>\n",
       "      <td>1.64</td>\n",
       "      <td>2.01</td>\n",
       "      <td>4.77</td>\n",
       "      <td>78.19</td>\n",
       "      <td>452.07</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.01</td>\n",
       "      <td>1.37</td>\n",
       "      <td>1.07</td>\n",
       "      <td>4.60</td>\n",
       "      <td>4.76</td>\n",
       "      <td>148.8</td>\n",
       "      <td>0.438</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.3</td>\n",
       "      <td>340.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>241.0</td>\n",
       "      <td>8.3</td>\n",
       "      <td>16.6</td>\n",
       "      <td>0.199</td>\n",
       "      <td>48.1</td>\n",
       "      <td>40.3</td>\n",
       "      <td>7.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>34.4775</td>\n",
       "      <td>63.69</td>\n",
       "      <td>15.23</td>\n",
       "      <td>21.786833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "      <td>25/10/2017</td>\n",
       "      <td>14.99</td>\n",
       "      <td>10.59</td>\n",
       "      <td>74.08</td>\n",
       "      <td>20.22</td>\n",
       "      <td>70.98</td>\n",
       "      <td>44.02</td>\n",
       "      <td>26.96</td>\n",
       "      <td>1.63</td>\n",
       "      <td>1.06</td>\n",
       "      <td>6.89</td>\n",
       "      <td>1.43</td>\n",
       "      <td>5.04</td>\n",
       "      <td>4.23</td>\n",
       "      <td>61.46</td>\n",
       "      <td>368.85</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>9.36</td>\n",
       "      <td>4.29</td>\n",
       "      <td>137.0</td>\n",
       "      <td>0.403</td>\n",
       "      <td>93.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>340.0</td>\n",
       "      <td>12.6</td>\n",
       "      <td>252.0</td>\n",
       "      <td>10.3</td>\n",
       "      <td>10.8</td>\n",
       "      <td>0.260</td>\n",
       "      <td>41.7</td>\n",
       "      <td>46.5</td>\n",
       "      <td>6.7</td>\n",
       "      <td>4.6</td>\n",
       "      <td>0.5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>29.9700</td>\n",
       "      <td>74.08</td>\n",
       "      <td>10.59</td>\n",
       "      <td>29.668948</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.07</td>\n",
       "      <td>14.78</td>\n",
       "      <td>75.79</td>\n",
       "      <td>22.72</td>\n",
       "      <td>78.05</td>\n",
       "      <td>41.83</td>\n",
       "      <td>36.22</td>\n",
       "      <td>1.15</td>\n",
       "      <td>0.97</td>\n",
       "      <td>5.37</td>\n",
       "      <td>1.27</td>\n",
       "      <td>3.65</td>\n",
       "      <td>4.86</td>\n",
       "      <td>77.18</td>\n",
       "      <td>341.67</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>5.07</td>\n",
       "      <td>5.15</td>\n",
       "      <td>106.0</td>\n",
       "      <td>0.354</td>\n",
       "      <td>68.7</td>\n",
       "      <td>20.6</td>\n",
       "      <td>299.0</td>\n",
       "      <td>16.6</td>\n",
       "      <td>316.0</td>\n",
       "      <td>11.1</td>\n",
       "      <td>14.0</td>\n",
       "      <td>0.350</td>\n",
       "      <td>56.6</td>\n",
       "      <td>33.1</td>\n",
       "      <td>9.1</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>33.3400</td>\n",
       "      <td>75.79</td>\n",
       "      <td>14.78</td>\n",
       "      <td>28.491832</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别  年龄        体检日期  *天门冬氨酸氨基转换酶  *丙氨酸氨基转换酶  *碱性磷酸酶  *r-谷氨酰基转换酶   *总蛋白  \\\n",
       "id                                                                          \n",
       "1    1  41  12/10/2017        24.96      23.10   99.59       20.23  76.88   \n",
       "2    1  41  19/10/2017        24.57      36.25   67.21       79.00  79.43   \n",
       "3    1  46  26/10/2017        20.82      15.23   63.69       38.17  86.23   \n",
       "4    0  22  25/10/2017        14.99      10.59   74.08       20.22  70.98   \n",
       "5    0  48  26/10/2017        20.07      14.78   75.79       22.72  78.05   \n",
       "\n",
       "      白蛋白   *球蛋白  白球比例  甘油三酯  总胆固醇  高密度脂蛋白胆固醇  低密度脂蛋白胆固醇    尿素     肌酐      尿酸  \\\n",
       "id                                                                              \n",
       "1   49.60  27.28  1.82  1.31  4.43       1.37       2.65  5.87  77.25  349.39   \n",
       "2   47.76  31.67  1.51  2.81  4.06       0.93       2.63  5.26  87.12  486.78   \n",
       "3   48.00  38.23  1.26  0.99  4.13       1.64       2.01  4.77  78.19  452.07   \n",
       "4   44.02  26.96  1.63  1.06  6.89       1.43       5.04  4.23  61.46  368.85   \n",
       "5   41.83  36.22  1.15  0.97  5.37       1.27       3.65  4.86  77.18  341.67   \n",
       "\n",
       "    乙肝表面抗原  乙肝表面抗体  乙肝e抗原  乙肝e抗体  乙肝核心抗体  白细胞计数  红细胞计数   血红蛋白  红细胞压积  红细胞平均体积  \\\n",
       "id                                                                              \n",
       "1     0.04    3.22   0.04   1.67    1.69   5.34   5.21  166.1  0.479     91.9   \n",
       "2     0.04    3.22   0.04   1.67    1.69   7.65   5.21  156.0  0.456     87.5   \n",
       "3     0.01    0.02   0.01   1.37    1.07   4.60   4.76  148.8  0.438     91.9   \n",
       "4     0.04    3.22   0.04   1.67    1.69   9.36   4.29  137.0  0.403     93.9   \n",
       "5     0.04    3.22   0.04   1.67    1.69   5.07   5.15  106.0  0.354     68.7   \n",
       "\n",
       "    红细胞平均血红蛋白量  红细胞平均血红蛋白浓度  红细胞体积分布宽度  血小板计数  血小板平均体积  血小板体积分布宽度  血小板比积  \\\n",
       "id                                                                         \n",
       "1         31.9        347.0       12.8  166.0      9.9       17.4  0.164   \n",
       "2         29.9        342.0       13.4  277.0      9.2       10.3  0.260   \n",
       "3         31.3        340.0       13.0  241.0      8.3       16.6  0.199   \n",
       "4         31.9        340.0       12.6  252.0     10.3       10.8  0.260   \n",
       "5         20.6        299.0       16.6  316.0     11.1       14.0  0.350   \n",
       "\n",
       "    中性粒细胞%  淋巴细胞%  单核细胞%  嗜酸细胞%  嗜碱细胞%  有无蛋白指标  有无固醇指标  有无血指标  有无细胞指标  有无酶指标  \\\n",
       "id                                                                             \n",
       "1     54.1   34.2    6.5    4.7    0.6       1       1      1       1      1   \n",
       "2     52.0   36.7    5.8    4.7    0.8       1       1      1       1      1   \n",
       "3     48.1   40.3    7.7    3.2    0.8       1       1      1       1      1   \n",
       "4     41.7   46.5    6.7    4.6    0.5       1       1      1       1      1   \n",
       "5     56.6   33.1    9.1    0.6    0.6       1       1      1       1      1   \n",
       "\n",
       "    有无尿指标  有无肝指标  缺失值数量   酶_mean  酶_max  酶_min      酶_std  \n",
       "id                                                         \n",
       "1       1      0      5  41.9700  99.59  20.23  38.462575  \n",
       "2       1      0      5  51.7575  79.00  24.57  25.564143  \n",
       "3       1      1      0  34.4775  63.69  15.23  21.786833  \n",
       "4       1      0      5  29.9700  74.08  10.59  29.668948  \n",
       "5       0      0      8  33.3400  75.79  14.78  28.491832  "
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 缺失值处理\n",
    "combined.fillna(combined.median(axis=0),inplace=True)\n",
    "combined.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# combined_age = combined.loc[:,'*天门冬氨酸氨基转换酶':'嗜碱细胞%'].apply(lambda x : x/combined['年龄'],axis=0)\n",
    "# combined = pd.concat([combined,combined_age],axis=1)\n",
    "# combined.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# from pylab import mpl\n",
    "# mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体\n",
    "# mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题\n",
    "# mpl.rcParams['axes.titlesize'] = 16\n",
    "# train.loc[:,'*天门冬氨酸氨基转换酶':'尿酸'].hist(bins=50,figsize=(40,30))\n",
    "# plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# train_copy = train.copy()\n",
    "# train_copy.dropna(thresh=21,inplace=True,axis=0)\n",
    "# 1- train_copy.apply(lambda x: x.count(),axis=0)/(train_copy.shape[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# train = pd.merge(train,train_test_rank,left_on='id',right_on='id',how='left')\n",
    "# train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别</th>\n",
       "      <th>年龄</th>\n",
       "      <th>体检日期</th>\n",
       "      <th>*天门冬氨酸氨基转换酶</th>\n",
       "      <th>*丙氨酸氨基转换酶</th>\n",
       "      <th>*碱性磷酸酶</th>\n",
       "      <th>*r-谷氨酰基转换酶</th>\n",
       "      <th>*总蛋白</th>\n",
       "      <th>白蛋白</th>\n",
       "      <th>*球蛋白</th>\n",
       "      <th>白球比例</th>\n",
       "      <th>甘油三酯</th>\n",
       "      <th>总胆固醇</th>\n",
       "      <th>高密度脂蛋白胆固醇</th>\n",
       "      <th>低密度脂蛋白胆固醇</th>\n",
       "      <th>尿素</th>\n",
       "      <th>肌酐</th>\n",
       "      <th>尿酸</th>\n",
       "      <th>乙肝表面抗原</th>\n",
       "      <th>乙肝表面抗体</th>\n",
       "      <th>乙肝e抗原</th>\n",
       "      <th>乙肝e抗体</th>\n",
       "      <th>乙肝核心抗体</th>\n",
       "      <th>白细胞计数</th>\n",
       "      <th>红细胞计数</th>\n",
       "      <th>血红蛋白</th>\n",
       "      <th>红细胞压积</th>\n",
       "      <th>红细胞平均体积</th>\n",
       "      <th>红细胞平均血红蛋白量</th>\n",
       "      <th>红细胞平均血红蛋白浓度</th>\n",
       "      <th>红细胞体积分布宽度</th>\n",
       "      <th>血小板计数</th>\n",
       "      <th>血小板平均体积</th>\n",
       "      <th>血小板体积分布宽度</th>\n",
       "      <th>血小板比积</th>\n",
       "      <th>中性粒细胞%</th>\n",
       "      <th>淋巴细胞%</th>\n",
       "      <th>单核细胞%</th>\n",
       "      <th>嗜酸细胞%</th>\n",
       "      <th>嗜碱细胞%</th>\n",
       "      <th>有无蛋白指标</th>\n",
       "      <th>有无固醇指标</th>\n",
       "      <th>有无血指标</th>\n",
       "      <th>有无细胞指标</th>\n",
       "      <th>有无酶指标</th>\n",
       "      <th>有无尿指标</th>\n",
       "      <th>有无肝指标</th>\n",
       "      <th>缺失值数量</th>\n",
       "      <th>酶_mean</th>\n",
       "      <th>酶_max</th>\n",
       "      <th>...</th>\n",
       "      <th>红细胞体积分布宽度*中性粒细胞%</th>\n",
       "      <th>红细胞体积分布宽度*淋巴细胞%</th>\n",
       "      <th>红细胞体积分布宽度*单核细胞%</th>\n",
       "      <th>红细胞体积分布宽度*嗜酸细胞%</th>\n",
       "      <th>红细胞体积分布宽度*嗜碱细胞%</th>\n",
       "      <th>血小板计数*血小板计数</th>\n",
       "      <th>血小板计数*血小板平均体积</th>\n",
       "      <th>血小板计数*血小板体积分布宽度</th>\n",
       "      <th>血小板计数*血小板比积</th>\n",
       "      <th>血小板计数*中性粒细胞%</th>\n",
       "      <th>血小板计数*淋巴细胞%</th>\n",
       "      <th>血小板计数*单核细胞%</th>\n",
       "      <th>血小板计数*嗜酸细胞%</th>\n",
       "      <th>血小板计数*嗜碱细胞%</th>\n",
       "      <th>血小板平均体积*血小板平均体积</th>\n",
       "      <th>血小板平均体积*血小板体积分布宽度</th>\n",
       "      <th>血小板平均体积*血小板比积</th>\n",
       "      <th>血小板平均体积*中性粒细胞%</th>\n",
       "      <th>血小板平均体积*淋巴细胞%</th>\n",
       "      <th>血小板平均体积*单核细胞%</th>\n",
       "      <th>血小板平均体积*嗜酸细胞%</th>\n",
       "      <th>血小板平均体积*嗜碱细胞%</th>\n",
       "      <th>血小板体积分布宽度*血小板体积分布宽度</th>\n",
       "      <th>血小板体积分布宽度*血小板比积</th>\n",
       "      <th>血小板体积分布宽度*中性粒细胞%</th>\n",
       "      <th>血小板体积分布宽度*淋巴细胞%</th>\n",
       "      <th>血小板体积分布宽度*单核细胞%</th>\n",
       "      <th>血小板体积分布宽度*嗜酸细胞%</th>\n",
       "      <th>血小板体积分布宽度*嗜碱细胞%</th>\n",
       "      <th>血小板比积*血小板比积</th>\n",
       "      <th>血小板比积*中性粒细胞%</th>\n",
       "      <th>血小板比积*淋巴细胞%</th>\n",
       "      <th>血小板比积*单核细胞%</th>\n",
       "      <th>血小板比积*嗜酸细胞%</th>\n",
       "      <th>血小板比积*嗜碱细胞%</th>\n",
       "      <th>中性粒细胞%*中性粒细胞%</th>\n",
       "      <th>中性粒细胞%*淋巴细胞%</th>\n",
       "      <th>中性粒细胞%*单核细胞%</th>\n",
       "      <th>中性粒细胞%*嗜酸细胞%</th>\n",
       "      <th>中性粒细胞%*嗜碱细胞%</th>\n",
       "      <th>淋巴细胞%*淋巴细胞%</th>\n",
       "      <th>淋巴细胞%*单核细胞%</th>\n",
       "      <th>淋巴细胞%*嗜酸细胞%</th>\n",
       "      <th>淋巴细胞%*嗜碱细胞%</th>\n",
       "      <th>单核细胞%*单核细胞%</th>\n",
       "      <th>单核细胞%*嗜酸细胞%</th>\n",
       "      <th>单核细胞%*嗜碱细胞%</th>\n",
       "      <th>嗜酸细胞%*嗜酸细胞%</th>\n",
       "      <th>嗜酸细胞%*嗜碱细胞%</th>\n",
       "      <th>嗜碱细胞%*嗜碱细胞%</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>12/10/2017</td>\n",
       "      <td>24.96</td>\n",
       "      <td>23.10</td>\n",
       "      <td>99.59</td>\n",
       "      <td>20.23</td>\n",
       "      <td>76.88</td>\n",
       "      <td>49.60</td>\n",
       "      <td>27.28</td>\n",
       "      <td>1.82</td>\n",
       "      <td>1.31</td>\n",
       "      <td>4.43</td>\n",
       "      <td>1.37</td>\n",
       "      <td>2.65</td>\n",
       "      <td>5.87</td>\n",
       "      <td>77.25</td>\n",
       "      <td>349.39</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>5.34</td>\n",
       "      <td>5.21</td>\n",
       "      <td>166.1</td>\n",
       "      <td>0.479</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>347.0</td>\n",
       "      <td>12.8</td>\n",
       "      <td>166.0</td>\n",
       "      <td>9.9</td>\n",
       "      <td>17.4</td>\n",
       "      <td>0.164</td>\n",
       "      <td>54.1</td>\n",
       "      <td>34.2</td>\n",
       "      <td>6.5</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>41.9700</td>\n",
       "      <td>99.59</td>\n",
       "      <td>...</td>\n",
       "      <td>692.48</td>\n",
       "      <td>437.76</td>\n",
       "      <td>83.20</td>\n",
       "      <td>60.16</td>\n",
       "      <td>7.68</td>\n",
       "      <td>27556.0</td>\n",
       "      <td>1643.4</td>\n",
       "      <td>2888.4</td>\n",
       "      <td>27.224</td>\n",
       "      <td>8980.6</td>\n",
       "      <td>5677.2</td>\n",
       "      <td>1079.0</td>\n",
       "      <td>780.2</td>\n",
       "      <td>99.6</td>\n",
       "      <td>98.01</td>\n",
       "      <td>172.26</td>\n",
       "      <td>1.6236</td>\n",
       "      <td>535.59</td>\n",
       "      <td>338.58</td>\n",
       "      <td>64.35</td>\n",
       "      <td>46.53</td>\n",
       "      <td>5.94</td>\n",
       "      <td>302.76</td>\n",
       "      <td>2.8536</td>\n",
       "      <td>941.34</td>\n",
       "      <td>595.08</td>\n",
       "      <td>113.10</td>\n",
       "      <td>81.78</td>\n",
       "      <td>10.44</td>\n",
       "      <td>0.026896</td>\n",
       "      <td>8.8724</td>\n",
       "      <td>5.6088</td>\n",
       "      <td>1.0660</td>\n",
       "      <td>0.7708</td>\n",
       "      <td>0.0984</td>\n",
       "      <td>2926.81</td>\n",
       "      <td>1850.22</td>\n",
       "      <td>351.65</td>\n",
       "      <td>254.27</td>\n",
       "      <td>32.46</td>\n",
       "      <td>1169.64</td>\n",
       "      <td>222.30</td>\n",
       "      <td>160.74</td>\n",
       "      <td>20.52</td>\n",
       "      <td>42.25</td>\n",
       "      <td>30.55</td>\n",
       "      <td>3.90</td>\n",
       "      <td>22.09</td>\n",
       "      <td>2.82</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>19/10/2017</td>\n",
       "      <td>24.57</td>\n",
       "      <td>36.25</td>\n",
       "      <td>67.21</td>\n",
       "      <td>79.00</td>\n",
       "      <td>79.43</td>\n",
       "      <td>47.76</td>\n",
       "      <td>31.67</td>\n",
       "      <td>1.51</td>\n",
       "      <td>2.81</td>\n",
       "      <td>4.06</td>\n",
       "      <td>0.93</td>\n",
       "      <td>2.63</td>\n",
       "      <td>5.26</td>\n",
       "      <td>87.12</td>\n",
       "      <td>486.78</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>7.65</td>\n",
       "      <td>5.21</td>\n",
       "      <td>156.0</td>\n",
       "      <td>0.456</td>\n",
       "      <td>87.5</td>\n",
       "      <td>29.9</td>\n",
       "      <td>342.0</td>\n",
       "      <td>13.4</td>\n",
       "      <td>277.0</td>\n",
       "      <td>9.2</td>\n",
       "      <td>10.3</td>\n",
       "      <td>0.260</td>\n",
       "      <td>52.0</td>\n",
       "      <td>36.7</td>\n",
       "      <td>5.8</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>51.7575</td>\n",
       "      <td>79.00</td>\n",
       "      <td>...</td>\n",
       "      <td>696.80</td>\n",
       "      <td>491.78</td>\n",
       "      <td>77.72</td>\n",
       "      <td>62.98</td>\n",
       "      <td>10.72</td>\n",
       "      <td>76729.0</td>\n",
       "      <td>2548.4</td>\n",
       "      <td>2853.1</td>\n",
       "      <td>72.020</td>\n",
       "      <td>14404.0</td>\n",
       "      <td>10165.9</td>\n",
       "      <td>1606.6</td>\n",
       "      <td>1301.9</td>\n",
       "      <td>221.6</td>\n",
       "      <td>84.64</td>\n",
       "      <td>94.76</td>\n",
       "      <td>2.3920</td>\n",
       "      <td>478.40</td>\n",
       "      <td>337.64</td>\n",
       "      <td>53.36</td>\n",
       "      <td>43.24</td>\n",
       "      <td>7.36</td>\n",
       "      <td>106.09</td>\n",
       "      <td>2.6780</td>\n",
       "      <td>535.60</td>\n",
       "      <td>378.01</td>\n",
       "      <td>59.74</td>\n",
       "      <td>48.41</td>\n",
       "      <td>8.24</td>\n",
       "      <td>0.067600</td>\n",
       "      <td>13.5200</td>\n",
       "      <td>9.5420</td>\n",
       "      <td>1.5080</td>\n",
       "      <td>1.2220</td>\n",
       "      <td>0.2080</td>\n",
       "      <td>2704.00</td>\n",
       "      <td>1908.40</td>\n",
       "      <td>301.60</td>\n",
       "      <td>244.40</td>\n",
       "      <td>41.60</td>\n",
       "      <td>1346.89</td>\n",
       "      <td>212.86</td>\n",
       "      <td>172.49</td>\n",
       "      <td>29.36</td>\n",
       "      <td>33.64</td>\n",
       "      <td>27.26</td>\n",
       "      <td>4.64</td>\n",
       "      <td>22.09</td>\n",
       "      <td>3.76</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>46</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.82</td>\n",
       "      <td>15.23</td>\n",
       "      <td>63.69</td>\n",
       "      <td>38.17</td>\n",
       "      <td>86.23</td>\n",
       "      <td>48.00</td>\n",
       "      <td>38.23</td>\n",
       "      <td>1.26</td>\n",
       "      <td>0.99</td>\n",
       "      <td>4.13</td>\n",
       "      <td>1.64</td>\n",
       "      <td>2.01</td>\n",
       "      <td>4.77</td>\n",
       "      <td>78.19</td>\n",
       "      <td>452.07</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.01</td>\n",
       "      <td>1.37</td>\n",
       "      <td>1.07</td>\n",
       "      <td>4.60</td>\n",
       "      <td>4.76</td>\n",
       "      <td>148.8</td>\n",
       "      <td>0.438</td>\n",
       "      <td>91.9</td>\n",
       "      <td>31.3</td>\n",
       "      <td>340.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>241.0</td>\n",
       "      <td>8.3</td>\n",
       "      <td>16.6</td>\n",
       "      <td>0.199</td>\n",
       "      <td>48.1</td>\n",
       "      <td>40.3</td>\n",
       "      <td>7.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>34.4775</td>\n",
       "      <td>63.69</td>\n",
       "      <td>...</td>\n",
       "      <td>625.30</td>\n",
       "      <td>523.90</td>\n",
       "      <td>100.10</td>\n",
       "      <td>41.60</td>\n",
       "      <td>10.40</td>\n",
       "      <td>58081.0</td>\n",
       "      <td>2000.3</td>\n",
       "      <td>4000.6</td>\n",
       "      <td>47.959</td>\n",
       "      <td>11592.1</td>\n",
       "      <td>9712.3</td>\n",
       "      <td>1855.7</td>\n",
       "      <td>771.2</td>\n",
       "      <td>192.8</td>\n",
       "      <td>68.89</td>\n",
       "      <td>137.78</td>\n",
       "      <td>1.6517</td>\n",
       "      <td>399.23</td>\n",
       "      <td>334.49</td>\n",
       "      <td>63.91</td>\n",
       "      <td>26.56</td>\n",
       "      <td>6.64</td>\n",
       "      <td>275.56</td>\n",
       "      <td>3.3034</td>\n",
       "      <td>798.46</td>\n",
       "      <td>668.98</td>\n",
       "      <td>127.82</td>\n",
       "      <td>53.12</td>\n",
       "      <td>13.28</td>\n",
       "      <td>0.039601</td>\n",
       "      <td>9.5719</td>\n",
       "      <td>8.0197</td>\n",
       "      <td>1.5323</td>\n",
       "      <td>0.6368</td>\n",
       "      <td>0.1592</td>\n",
       "      <td>2313.61</td>\n",
       "      <td>1938.43</td>\n",
       "      <td>370.37</td>\n",
       "      <td>153.92</td>\n",
       "      <td>38.48</td>\n",
       "      <td>1624.09</td>\n",
       "      <td>310.31</td>\n",
       "      <td>128.96</td>\n",
       "      <td>32.24</td>\n",
       "      <td>59.29</td>\n",
       "      <td>24.64</td>\n",
       "      <td>6.16</td>\n",
       "      <td>10.24</td>\n",
       "      <td>2.56</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "      <td>25/10/2017</td>\n",
       "      <td>14.99</td>\n",
       "      <td>10.59</td>\n",
       "      <td>74.08</td>\n",
       "      <td>20.22</td>\n",
       "      <td>70.98</td>\n",
       "      <td>44.02</td>\n",
       "      <td>26.96</td>\n",
       "      <td>1.63</td>\n",
       "      <td>1.06</td>\n",
       "      <td>6.89</td>\n",
       "      <td>1.43</td>\n",
       "      <td>5.04</td>\n",
       "      <td>4.23</td>\n",
       "      <td>61.46</td>\n",
       "      <td>368.85</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>9.36</td>\n",
       "      <td>4.29</td>\n",
       "      <td>137.0</td>\n",
       "      <td>0.403</td>\n",
       "      <td>93.9</td>\n",
       "      <td>31.9</td>\n",
       "      <td>340.0</td>\n",
       "      <td>12.6</td>\n",
       "      <td>252.0</td>\n",
       "      <td>10.3</td>\n",
       "      <td>10.8</td>\n",
       "      <td>0.260</td>\n",
       "      <td>41.7</td>\n",
       "      <td>46.5</td>\n",
       "      <td>6.7</td>\n",
       "      <td>4.6</td>\n",
       "      <td>0.5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>29.9700</td>\n",
       "      <td>74.08</td>\n",
       "      <td>...</td>\n",
       "      <td>525.42</td>\n",
       "      <td>585.90</td>\n",
       "      <td>84.42</td>\n",
       "      <td>57.96</td>\n",
       "      <td>6.30</td>\n",
       "      <td>63504.0</td>\n",
       "      <td>2595.6</td>\n",
       "      <td>2721.6</td>\n",
       "      <td>65.520</td>\n",
       "      <td>10508.4</td>\n",
       "      <td>11718.0</td>\n",
       "      <td>1688.4</td>\n",
       "      <td>1159.2</td>\n",
       "      <td>126.0</td>\n",
       "      <td>106.09</td>\n",
       "      <td>111.24</td>\n",
       "      <td>2.6780</td>\n",
       "      <td>429.51</td>\n",
       "      <td>478.95</td>\n",
       "      <td>69.01</td>\n",
       "      <td>47.38</td>\n",
       "      <td>5.15</td>\n",
       "      <td>116.64</td>\n",
       "      <td>2.8080</td>\n",
       "      <td>450.36</td>\n",
       "      <td>502.20</td>\n",
       "      <td>72.36</td>\n",
       "      <td>49.68</td>\n",
       "      <td>5.40</td>\n",
       "      <td>0.067600</td>\n",
       "      <td>10.8420</td>\n",
       "      <td>12.0900</td>\n",
       "      <td>1.7420</td>\n",
       "      <td>1.1960</td>\n",
       "      <td>0.1300</td>\n",
       "      <td>1738.89</td>\n",
       "      <td>1939.05</td>\n",
       "      <td>279.39</td>\n",
       "      <td>191.82</td>\n",
       "      <td>20.85</td>\n",
       "      <td>2162.25</td>\n",
       "      <td>311.55</td>\n",
       "      <td>213.90</td>\n",
       "      <td>23.25</td>\n",
       "      <td>44.89</td>\n",
       "      <td>30.82</td>\n",
       "      <td>3.35</td>\n",
       "      <td>21.16</td>\n",
       "      <td>2.30</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>26/10/2017</td>\n",
       "      <td>20.07</td>\n",
       "      <td>14.78</td>\n",
       "      <td>75.79</td>\n",
       "      <td>22.72</td>\n",
       "      <td>78.05</td>\n",
       "      <td>41.83</td>\n",
       "      <td>36.22</td>\n",
       "      <td>1.15</td>\n",
       "      <td>0.97</td>\n",
       "      <td>5.37</td>\n",
       "      <td>1.27</td>\n",
       "      <td>3.65</td>\n",
       "      <td>4.86</td>\n",
       "      <td>77.18</td>\n",
       "      <td>341.67</td>\n",
       "      <td>0.04</td>\n",
       "      <td>3.22</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.67</td>\n",
       "      <td>1.69</td>\n",
       "      <td>5.07</td>\n",
       "      <td>5.15</td>\n",
       "      <td>106.0</td>\n",
       "      <td>0.354</td>\n",
       "      <td>68.7</td>\n",
       "      <td>20.6</td>\n",
       "      <td>299.0</td>\n",
       "      <td>16.6</td>\n",
       "      <td>316.0</td>\n",
       "      <td>11.1</td>\n",
       "      <td>14.0</td>\n",
       "      <td>0.350</td>\n",
       "      <td>56.6</td>\n",
       "      <td>33.1</td>\n",
       "      <td>9.1</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>33.3400</td>\n",
       "      <td>75.79</td>\n",
       "      <td>...</td>\n",
       "      <td>939.56</td>\n",
       "      <td>549.46</td>\n",
       "      <td>151.06</td>\n",
       "      <td>9.96</td>\n",
       "      <td>9.96</td>\n",
       "      <td>99856.0</td>\n",
       "      <td>3507.6</td>\n",
       "      <td>4424.0</td>\n",
       "      <td>110.600</td>\n",
       "      <td>17885.6</td>\n",
       "      <td>10459.6</td>\n",
       "      <td>2875.6</td>\n",
       "      <td>189.6</td>\n",
       "      <td>189.6</td>\n",
       "      <td>123.21</td>\n",
       "      <td>155.40</td>\n",
       "      <td>3.8850</td>\n",
       "      <td>628.26</td>\n",
       "      <td>367.41</td>\n",
       "      <td>101.01</td>\n",
       "      <td>6.66</td>\n",
       "      <td>6.66</td>\n",
       "      <td>196.00</td>\n",
       "      <td>4.9000</td>\n",
       "      <td>792.40</td>\n",
       "      <td>463.40</td>\n",
       "      <td>127.40</td>\n",
       "      <td>8.40</td>\n",
       "      <td>8.40</td>\n",
       "      <td>0.122500</td>\n",
       "      <td>19.8100</td>\n",
       "      <td>11.5850</td>\n",
       "      <td>3.1850</td>\n",
       "      <td>0.2100</td>\n",
       "      <td>0.2100</td>\n",
       "      <td>3203.56</td>\n",
       "      <td>1873.46</td>\n",
       "      <td>515.06</td>\n",
       "      <td>33.96</td>\n",
       "      <td>33.96</td>\n",
       "      <td>1095.61</td>\n",
       "      <td>301.21</td>\n",
       "      <td>19.86</td>\n",
       "      <td>19.86</td>\n",
       "      <td>82.81</td>\n",
       "      <td>5.46</td>\n",
       "      <td>5.46</td>\n",
       "      <td>0.36</td>\n",
       "      <td>0.36</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 1528 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别  年龄        体检日期  *天门冬氨酸氨基转换酶  *丙氨酸氨基转换酶  *碱性磷酸酶  *r-谷氨酰基转换酶   *总蛋白  \\\n",
       "id                                                                          \n",
       "1    1  41  12/10/2017        24.96      23.10   99.59       20.23  76.88   \n",
       "2    1  41  19/10/2017        24.57      36.25   67.21       79.00  79.43   \n",
       "3    1  46  26/10/2017        20.82      15.23   63.69       38.17  86.23   \n",
       "4    0  22  25/10/2017        14.99      10.59   74.08       20.22  70.98   \n",
       "5    0  48  26/10/2017        20.07      14.78   75.79       22.72  78.05   \n",
       "\n",
       "      白蛋白   *球蛋白  白球比例  甘油三酯  总胆固醇  高密度脂蛋白胆固醇  低密度脂蛋白胆固醇    尿素     肌酐      尿酸  \\\n",
       "id                                                                              \n",
       "1   49.60  27.28  1.82  1.31  4.43       1.37       2.65  5.87  77.25  349.39   \n",
       "2   47.76  31.67  1.51  2.81  4.06       0.93       2.63  5.26  87.12  486.78   \n",
       "3   48.00  38.23  1.26  0.99  4.13       1.64       2.01  4.77  78.19  452.07   \n",
       "4   44.02  26.96  1.63  1.06  6.89       1.43       5.04  4.23  61.46  368.85   \n",
       "5   41.83  36.22  1.15  0.97  5.37       1.27       3.65  4.86  77.18  341.67   \n",
       "\n",
       "    乙肝表面抗原  乙肝表面抗体  乙肝e抗原  乙肝e抗体  乙肝核心抗体  白细胞计数  红细胞计数   血红蛋白  红细胞压积  红细胞平均体积  \\\n",
       "id                                                                              \n",
       "1     0.04    3.22   0.04   1.67    1.69   5.34   5.21  166.1  0.479     91.9   \n",
       "2     0.04    3.22   0.04   1.67    1.69   7.65   5.21  156.0  0.456     87.5   \n",
       "3     0.01    0.02   0.01   1.37    1.07   4.60   4.76  148.8  0.438     91.9   \n",
       "4     0.04    3.22   0.04   1.67    1.69   9.36   4.29  137.0  0.403     93.9   \n",
       "5     0.04    3.22   0.04   1.67    1.69   5.07   5.15  106.0  0.354     68.7   \n",
       "\n",
       "    红细胞平均血红蛋白量  红细胞平均血红蛋白浓度  红细胞体积分布宽度  血小板计数  血小板平均体积  血小板体积分布宽度  血小板比积  \\\n",
       "id                                                                         \n",
       "1         31.9        347.0       12.8  166.0      9.9       17.4  0.164   \n",
       "2         29.9        342.0       13.4  277.0      9.2       10.3  0.260   \n",
       "3         31.3        340.0       13.0  241.0      8.3       16.6  0.199   \n",
       "4         31.9        340.0       12.6  252.0     10.3       10.8  0.260   \n",
       "5         20.6        299.0       16.6  316.0     11.1       14.0  0.350   \n",
       "\n",
       "    中性粒细胞%  淋巴细胞%  单核细胞%  嗜酸细胞%  嗜碱细胞%  有无蛋白指标  有无固醇指标  有无血指标  有无细胞指标  有无酶指标  \\\n",
       "id                                                                             \n",
       "1     54.1   34.2    6.5    4.7    0.6       1       1      1       1      1   \n",
       "2     52.0   36.7    5.8    4.7    0.8       1       1      1       1      1   \n",
       "3     48.1   40.3    7.7    3.2    0.8       1       1      1       1      1   \n",
       "4     41.7   46.5    6.7    4.6    0.5       1       1      1       1      1   \n",
       "5     56.6   33.1    9.1    0.6    0.6       1       1      1       1      1   \n",
       "\n",
       "    有无尿指标  有无肝指标  缺失值数量   酶_mean  酶_max     ...       红细胞体积分布宽度*中性粒细胞%  \\\n",
       "id                                          ...                          \n",
       "1       1      0      5  41.9700  99.59     ...                 692.48   \n",
       "2       1      0      5  51.7575  79.00     ...                 696.80   \n",
       "3       1      1      0  34.4775  63.69     ...                 625.30   \n",
       "4       1      0      5  29.9700  74.08     ...                 525.42   \n",
       "5       0      0      8  33.3400  75.79     ...                 939.56   \n",
       "\n",
       "    红细胞体积分布宽度*淋巴细胞% 红细胞体积分布宽度*单核细胞% 红细胞体积分布宽度*嗜酸细胞% 红细胞体积分布宽度*嗜碱细胞%  \\\n",
       "id                                                                    \n",
       "1            437.76           83.20           60.16            7.68   \n",
       "2            491.78           77.72           62.98           10.72   \n",
       "3            523.90          100.10           41.60           10.40   \n",
       "4            585.90           84.42           57.96            6.30   \n",
       "5            549.46          151.06            9.96            9.96   \n",
       "\n",
       "   血小板计数*血小板计数 血小板计数*血小板平均体积 血小板计数*血小板体积分布宽度 血小板计数*血小板比积 血小板计数*中性粒细胞%  \\\n",
       "id                                                                      \n",
       "1      27556.0        1643.4          2888.4      27.224       8980.6   \n",
       "2      76729.0        2548.4          2853.1      72.020      14404.0   \n",
       "3      58081.0        2000.3          4000.6      47.959      11592.1   \n",
       "4      63504.0        2595.6          2721.6      65.520      10508.4   \n",
       "5      99856.0        3507.6          4424.0     110.600      17885.6   \n",
       "\n",
       "   血小板计数*淋巴细胞% 血小板计数*单核细胞% 血小板计数*嗜酸细胞% 血小板计数*嗜碱细胞% 血小板平均体积*血小板平均体积  \\\n",
       "id                                                                   \n",
       "1       5677.2      1079.0       780.2        99.6           98.01   \n",
       "2      10165.9      1606.6      1301.9       221.6           84.64   \n",
       "3       9712.3      1855.7       771.2       192.8           68.89   \n",
       "4      11718.0      1688.4      1159.2       126.0          106.09   \n",
       "5      10459.6      2875.6       189.6       189.6          123.21   \n",
       "\n",
       "   血小板平均体积*血小板体积分布宽度 血小板平均体积*血小板比积 血小板平均体积*中性粒细胞% 血小板平均体积*淋巴细胞% 血小板平均体积*单核细胞%  \\\n",
       "id                                                                              \n",
       "1             172.26        1.6236         535.59        338.58         64.35   \n",
       "2              94.76        2.3920         478.40        337.64         53.36   \n",
       "3             137.78        1.6517         399.23        334.49         63.91   \n",
       "4             111.24        2.6780         429.51        478.95         69.01   \n",
       "5             155.40        3.8850         628.26        367.41        101.01   \n",
       "\n",
       "   血小板平均体积*嗜酸细胞% 血小板平均体积*嗜碱细胞% 血小板体积分布宽度*血小板体积分布宽度 血小板体积分布宽度*血小板比积  \\\n",
       "id                                                                   \n",
       "1          46.53          5.94              302.76          2.8536   \n",
       "2          43.24          7.36              106.09          2.6780   \n",
       "3          26.56          6.64              275.56          3.3034   \n",
       "4          47.38          5.15              116.64          2.8080   \n",
       "5           6.66          6.66              196.00          4.9000   \n",
       "\n",
       "   血小板体积分布宽度*中性粒细胞% 血小板体积分布宽度*淋巴细胞% 血小板体积分布宽度*单核细胞% 血小板体积分布宽度*嗜酸细胞%  \\\n",
       "id                                                                    \n",
       "1            941.34          595.08          113.10           81.78   \n",
       "2            535.60          378.01           59.74           48.41   \n",
       "3            798.46          668.98          127.82           53.12   \n",
       "4            450.36          502.20           72.36           49.68   \n",
       "5            792.40          463.40          127.40            8.40   \n",
       "\n",
       "   血小板体积分布宽度*嗜碱细胞% 血小板比积*血小板比积 血小板比积*中性粒细胞% 血小板比积*淋巴细胞% 血小板比积*单核细胞%  \\\n",
       "id                                                                    \n",
       "1            10.44    0.026896       8.8724      5.6088      1.0660   \n",
       "2             8.24    0.067600      13.5200      9.5420      1.5080   \n",
       "3            13.28    0.039601       9.5719      8.0197      1.5323   \n",
       "4             5.40    0.067600      10.8420     12.0900      1.7420   \n",
       "5             8.40    0.122500      19.8100     11.5850      3.1850   \n",
       "\n",
       "   血小板比积*嗜酸细胞%  血小板比积*嗜碱细胞%  中性粒细胞%*中性粒细胞%  中性粒细胞%*淋巴细胞%  中性粒细胞%*单核细胞%  \\\n",
       "id                                                                       \n",
       "1       0.7708       0.0984        2926.81       1850.22        351.65   \n",
       "2       1.2220       0.2080        2704.00       1908.40        301.60   \n",
       "3       0.6368       0.1592        2313.61       1938.43        370.37   \n",
       "4       1.1960       0.1300        1738.89       1939.05        279.39   \n",
       "5       0.2100       0.2100        3203.56       1873.46        515.06   \n",
       "\n",
       "    中性粒细胞%*嗜酸细胞%  中性粒细胞%*嗜碱细胞%  淋巴细胞%*淋巴细胞%  淋巴细胞%*单核细胞%  淋巴细胞%*嗜酸细胞%  \\\n",
       "id                                                                      \n",
       "1         254.27         32.46      1169.64       222.30       160.74   \n",
       "2         244.40         41.60      1346.89       212.86       172.49   \n",
       "3         153.92         38.48      1624.09       310.31       128.96   \n",
       "4         191.82         20.85      2162.25       311.55       213.90   \n",
       "5          33.96         33.96      1095.61       301.21        19.86   \n",
       "\n",
       "    淋巴细胞%*嗜碱细胞%  单核细胞%*单核细胞%  单核细胞%*嗜酸细胞%  单核细胞%*嗜碱细胞%  嗜酸细胞%*嗜酸细胞%  \\\n",
       "id                                                                    \n",
       "1         20.52        42.25        30.55         3.90        22.09   \n",
       "2         29.36        33.64        27.26         4.64        22.09   \n",
       "3         32.24        59.29        24.64         6.16        10.24   \n",
       "4         23.25        44.89        30.82         3.35        21.16   \n",
       "5         19.86        82.81         5.46         5.46         0.36   \n",
       "\n",
       "    嗜酸细胞%*嗜碱细胞%  嗜碱细胞%*嗜碱细胞%  \n",
       "id                            \n",
       "1          2.82         0.36  \n",
       "2          3.76         0.64  \n",
       "3          2.56         0.64  \n",
       "4          2.30         0.25  \n",
       "5          0.36         0.36  \n",
       "\n",
       "[5 rows x 1528 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "combined = pd.concat([combined,combined_cut,combined_ratio,combined_mul],axis=1)\n",
    "combined.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7642, 1528)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# # y = pd.DataFrame(y)\n",
    "# # pd.concat([y,test_real_y])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# train = train[train['血糖']<=20]\n",
    "\n",
    "# y = combined['血糖']\n",
    "# combined.drop(['体检日期'],axis=1,inplace=True)\n",
    "train = combined.loc[train_index]\n",
    "test = combined.loc[test_index]\n",
    "train.to_csv('../train_data.csv',index=True)\n",
    "test.to_csv('../test_data.csv',index=True)\n",
    "y = pd.DataFrame(y)\n",
    "test_real_y.rename(columns={0:'血糖'},inplace=True)\n",
    "y = pd.concat([y,test_real_y])\n",
    "y.index = train.index\n",
    "y.to_csv('../targets.csv',index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>血糖</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5.42</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      血糖\n",
       "id      \n",
       "1   6.06\n",
       "2   5.39\n",
       "3   5.59\n",
       "4   4.30\n",
       "5   5.42"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "combined_ratio['年龄'] = combined['年龄']\n",
    "y = pd.DataFrame(y)\n",
    "y.to_csv('../targets.csv',index=True)\n",
    "# combined.drop(['血糖'],axis=1,inplace=True)\n",
    "train = combined_ratio.loc[train_index]\n",
    "test = combined_ratio.loc[test_index]\n",
    "train.to_csv('../train_data_ratio.csv',index=True)\n",
    "test.to_csv('../test_data_ratio.csv',index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y.to_csv('../targets.csv',index=True)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
